WordPress.org

Ready to get started?Download WordPress

Forums

Yoko
Remove entry details in search results (5 posts)

  1. thomasmpreston
    Member
    Posted 1 year ago #

    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:

    http://amwellburypress.co.uk/?s=shop

    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?

    Thanks!

  2. Tareq
    Member
    Posted 1 year ago #

    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,

    Tareq

  3. thomasmpreston
    Member
    Posted 1 year ago #

    Hi,

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

    <?php
    /**
     * @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>
    					</header>
    
    					<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(); ?>
    					</div>
    				</article>
    
    			<?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.

  4. Tareq
    Member
    Posted 1 year ago #

    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.

    Regards,

    Tareq

  5. cbush57
    Member
    Posted 9 months ago #

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

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic