WordPress.org

Forums

[resolved] Make image attachment page Title link to the page with gallery (2 posts)

  1. gr8
    Member
    Posted 2 years ago #

    Hi. I would like to have the image attachment page title link to the page I've added a default image gallery on my Twenty Twelve child theme.

    So when a thumbnail is clicked on and the attachment page opens it gives the previous or next image link options and I would like to make the titles (h1 class entry-title pagetitle h1) of the gallery's image attachment pages link to the page that the gallery was attached to.

    I have added an image attachment template php file to my child theme and just can't figure out how to link the h1 title back to the page I added the galley to.

    This is pretty much a stock twenty twelve child theme and the default image gallery set to attachment page so I don't imagine a link to my site would help. Any suggestions would be greatly appreciated, need sleep:)

  2. gr8
    Member
    Posted 2 years ago #

    Asking the correct question was the answer. This adds an additional linked "page title" (not entry title) that returns to the page where the images are attached. In the attachment image template php of my twenty twelve child theme I added:

    <?php if ( ! empty( $post->post_parent ) ) : ?>
    					<p class="page-title"><a href="<?php echo get_permalink( $post->post_parent ); ?>" title="<?php esc_attr( printf( __( 'Return to %s', '' ), get_the_title( $post->post_parent ) ) ); ?>" rel="gallery"><?php
    						printf( __( '<span class="meta-nav">←</span> %s', '' ), get_the_title( $post->post_parent ) );
    					?></a></p>
    				<?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic