• Resolved screamingrooster

    (@screamingrooster)


    Just started using tag cloud and very impressed!

    I have set up an ‘alpahbetical tag index’ with a slightly modified index template in my child theme:

    <?php get_header(); ?>
    
      <?php get_template_part( 'template-parts/global/wrapper-before-blog' ); ?>
    
      <h4 class="search-title">Cellar Stage has 
    <?php echo $wp_query->found_posts; ?> <?php _e( 'results')?><br>
    </h4>
    
          <?php if ( have_posts() ) : ?>
    
            <div class="ct-posts">
    
              <?php while ( have_posts() ) : the_post(); ?>
    			
              <?php get_template_part( 'post-formats/content', 'search' ); ?>
    
              <?php endwhile; ?>
    
            </div>
    
            <?php get_template_part( 'template-parts/pagination' , 'posts' ); ?>
    
          <?php else : get_template_part( 'post-formats/content' , 'missing' ); endif; ?>
    
      <?php get_template_part( 'template-parts/global/wrapper-after-blog' ); ?>
      
        <h4 class="search-title">Another search?:  
    <?php get_search_form( true ); ?></h4>
    
    <?php rcblock_by_id( "6302" ); ?>
    
    <?php get_footer(); ?>

    It calls content-search (which I use for the normal WP search):

    <article id="post-<?php the_ID(); ?>" <?php post_class( 'ct-post entry' ); ?>>
      <h4 class="search-title">Cellar Stage has 
    <?php echo $wp_query->found_posts; ?> <?php _e( 'Results For', 'locale' ); ?>: "<?php the_search_query(); ?>"<br>
    </h4>
    	<header>
    		<h4 class="search-title"><?php get_template_part( 'template-parts/title', 'loop' ); ?></h4>
    		<?php get_template_part( 'template-parts/featured', 'image' ); ?>
    		<?php get_template_part( 'template-parts/meta', 'loop' ); ?>
    	</header>
    
    	<div class="ct-post__excerpt">
    		<?php the_excerpt(); ?>
    	</div>
    
    	<?php get_template_part( 'template-parts/button', 'read-more'); ?>
    
    </article>

    It works perfectly except it does not show the ‘template-parts/featured’, ‘image’,
    as my normal search results do. Any idea with what I am doing wrong?

    Thanks in advance for your response.

    Kindest

    Colin

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

Viewing 1 replies (of 1 total)
  • Hi Colin,

    Sorry, I’m not very experienced with WordPress templates. Some ideas come to my mind:

    • Make sure that there is indeed a file template-parts/featured-image.php. Maybe you have a typo in the file name?
    • You could var_dump the return value of get_template_part( 'template-parts/featured', 'image' ); for debugging. It will be false if the template cannot be found.
    • Maybe the template needs a particular format, like a header in the code. If the ‘loop’ template works, you could compare these two files.
    • Maybe the template does load but its content is not visible. E.g. the image path is wrong.

    I hope that this helps.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting featured image in serach results’ is closed to new replies.