• My attachment page lok like this:

    <?php
    /**
     * The template for displaying all single posts.
     *
     * 
     */
    
    get_header(); ?>
    
    	<section id="primary" class="content-single content-area">
    		<main id="main" class="site-main" role="main">
    				
    		<?php while ( have_posts() ) : the_post();
    
    			get_template_part( 'template-parts/content', 'single' );
    
    			tortuga_related_posts();
    
    			comments_template();
    
    		endwhile; ?>
    		
    		</main><!-- #main -->
    	</section><!-- #primary -->
    	
    	<?php get_sidebar(); ?>
    	
    <?php get_footer(); ?>

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • In my theme, I use a filter.

    function twenty8teen_attachment( $p ) {
      $apost = get_post();
      $p .= $apost->post_excerpt ? ( '<p class="wp-caption-text">'. wptexturize( $apost->post_excerpt ) . '</p>' ) : '';
      return $p;
    }
    add_filter('prepend_attachment', 'twenty8teen_attachment');

    You have to try it to see if the caption comes out in the right place for your theme. Also, make sure it’s okay for other file types.
    You could also make a separate template part for image attachments, where you get the excerpt (caption).

Viewing 1 replies (of 1 total)
  • The topic ‘How do I display the caption of an image on the attachment page?’ is closed to new replies.