Support » Theme: Yoko » Remove entry details in search results

  • Hi,

    Trying to modify my child theme so that the search results return just the entry header/content and not the post details (such as author, date etc) as well.

    Here’s a search page for you to see:

    I only have pages on the site (at the moment) not posts and don’t want the date, author or comments link showing up there. Is there a simple way to remove this part of the result that I’m missing?


Viewing 4 replies - 1 through 4 (of 4 total)
  • Tareq


    Do you have anything like a search.php file in your main Theme directory?

    If you comment out the entry-details div you should be OK!




    Thanks, yes I do, although that <div> doesn’t exist in that file. Here’s the code:

     * @package WordPress
     * @subpackage Yoko
    get_header(); ?>
    <div id="wrap">
    	<div id="main">
    	<div id="content">
    			<?php if ( have_posts() ) : ?>
    				<header class="page-header">
    					<h1 class="page-title"><?php echo $wp_query->found_posts; ?> <?php printf( __( 'Search Results for: %s', 'yoko' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    				</header><!--end page-header-->
    				<?php /* Start the Loop */ ?>
    				<?php while ( have_posts() ) : the_post(); ?>
    					<?php get_template_part( 'content', 'search' ); ?>
    				<?php endwhile; ?>
    				<?php /* Display navigation to next/previous pages when applicable */ ?>
    				<?php if (  $wp_query->max_num_pages > 1 ) : ?>
    					<nav id="nav-below">
    						<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'yoko' ) ); ?></div>
    						<div class="nav-next"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'yoko' ) ); ?></div>
    					</nav><!-- end nav-below -->
    				<?php endif; ?>
    			<?php else : ?>
    				<article id="post-0" class="post no-results not-found">
    					<header class="page-header">
    						<h1 class="page-title"><?php _e( 'Nothing Found', 'yoko' ); ?></h1>
    					<div class="single-entry-content">
    						<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'yoko' ); ?></p>
    						<?php get_search_form(); ?>
    			<?php endif; ?>
    	</div><!-- end content -->
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I can see when I ‘inspect element’ that’s the <div> with the info but not sure how to hide it for search results here.



    Ah OK!

    We can see that it calls in the ‘content‘ and ‘search‘ by using the get_template_part() function.

    In this case, the code you’ll be looking to edit will be in content.php.

    Basically, open up content.php and remove or comment out the following lines of code:

    <p><?php echo get_the_date(); ?><br/>
    		<?php _e( 'by', 'yoko' ); ?> <?php the_author() ?><br/>
    		<?php comments_popup_link( __( '0 comments', 'yoko' ), __( '1 Comment', 'yoko' ), __( '% Comments', 'yoko' ) ); ?></p>

    Make sure you remove the <p> and </p> otherwise you’ll get some formatting issues.

    Let me know if this has helped.



    Thanks worthingtech!! This is exactly what I was looking for too.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove entry details in search results’ is closed to new replies.