• Eric Hepperle

    (@codeslayer2010)


    How can I customize the search results page to display the excerpt only?

    I like the Shop Isle theme, but either it is too complicated/layered or do versions of WordPress themes since 2016 require an additional level of abstraction?

    WHAT I TRIED ALREADY:

    I checked search.php, which seemed like an intutive place to keep the code for search results. But, the code was not there. Instead it led me to another file called content.php, but the code to edit wasn’t in that file either. I even wrote a blog post about my struggle here: https://erichepperle.com/developer-journal-wp-shop-isle-search-excerpts/

    This is all it says in content.php:

    <div <?php post_class( 'post' ); ?> id="post-<?php the_ID(); ?>">
    
    	<?php
    
    	/*
    	 * @hooked shop_isle_post_header() - 10
    	 * @hooked shop_isle_post_meta() - 20
    	 * @hooked shop_isle_post_content() - 30
    	 */
    	do_action( 'shop_isle_loop_post' );
    	?>
    
    </div><!-- #post-## -->

    It seems that “@hooked shop_isle_post_content()” or “shop_isle_loop_post” are the important lines of code. But neither of these correlate with a php filename.

    I’m stumped. Any help is appreciated.

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

Viewing 1 replies (of 1 total)
  • Hi @codeslayer2010,

    Sorry for my late reply. Try adding this function in a child theme:

    function shop_isle_post_content() {
    		global $post;
    		echo '<div class="post-entry entry-content">';
    
    		$shop_isleismore = strpos( $post->post_content, '<!--more' );
    		if ( $shop_isleismore ) :
    			the_content();
    		else :
    			the_excerpt();
    		endif;
    
    		echo '</div>';
    
    		$tags_list = get_the_tag_list( '', esc_html__( ', ', 'shop-isle' ) );
    		if ( $tags_list ) {
    			printf(
    			/* translators: s: post title */
    				'<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'shop-isle' ) . '</span>',
    				$tags_list
    			);
    		}
    	}
Viewing 1 replies (of 1 total)
  • The topic ‘Customizing Search Results page to show the excerpt’ is closed to new replies.