• I create a post with image linked to “attachment page” and not to a “media file”.

    If the post has one single attachment and if i click to this image (image.php):

    $metadata = wp_get_attachment_metadata();

    works fine, and so i can go to post_parent.

    If the post has a gallery, metadata return only link to post (title of the image) and not to post_parent.

    For example:

    <?php echo get_the_title( $post->post_parent ) ?>

    works in image.php only if the post has one image. If the post has a gallery, post_parent display only the title of the attachment, and doesn’t display title of post_parent.

    Code of metadata in image.php is the default code:

    <?php
    
                                $metadata = wp_get_attachment_metadata();
                                printf( __( '<span class="meta-prep meta-prep-entry-date">Published </span> <span class="entry-date"><time class="entry-date" datetime="%1$s">%2$s</time></span> at <a href="%3$s" title="Link to full-size image">%4$s &times; %5$s</a> in <a href="%6$s" title="Return to %7$s" rel="gallery">%8$s</a>.', 'twentytwelve' ),
                                    esc_attr( get_the_date( 'c' ) ),
                                    esc_html( get_the_date() ),
                                    esc_url( wp_get_attachment_url() ),
                                    $metadata['width'],
                                    $metadata['height'],
                                    esc_url( get_permalink( $post->post_parent ) ),
                                    esc_attr( strip_tags( get_the_title( $post->post_parent ) ) ),
                                    get_the_title( $post->post_parent )
                                );
                            ?>

    Why this happens? There is a solution?

  • The topic ‘Attachment doesn't get post_parent gallery in multisite’ is closed to new replies.