Site icon T4Tutorials.com

show only the post titles with WP search and don’t show description or meta data

Let me tell you “How to show only the post titles with WP search and don’t show description or meta data”?

show only the post titles with WP search and don't show description or meta data
show only the post titles with WP search and don’t show description or meta data
  1. Open the admin dashboard.
  2. Select Appearance
  3. Select Theme File Editor.
  4. Open search.php.
  5. Find the section of code that outputs the search results. This may vary depending on your theme, but mostly it involved a loop that outputs each result.
  6. Find the code that outputs the post title.
  7. This code I find in search.php of my wp theme.
<div class="news-list-post-wrap column--one">
									
									<?php
									while ( have_posts() ) : the_post(); ?>

										<li><font><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></font></li>
									
<?php endwhile; 
									
									
										do_action( 'digital_newspaper_pagination_link_hook' );			?>
									
					
									
								</div>

 

  1. I replaced the above code with the code given below to update search.php
<?php
									while ( have_posts() ) : the_post(); ?>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php endwhile; ?>'
  1. Now, only post title will appear in search results.
Exit mobile version