Tuesday, March 6, 2018

Remove excert from WordPress standard search



The standard search box generates by default a list of titles and excerpts.

The bold text is the title, the other (smaller characters) is the excerpt.

To exclude the excerpt from the default search, check the theme the site is using.
In this example is TwentyFifteen.
Go to the theme's folder and follow the procedure below.



1. Edit content-search.php.
This file is at:

/home/mynumbers/public_html/wp-content/themes/twentyfifteen/content-search.php


2. Remove the entry in orange:

 <header class="entry-header">
  <?php the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
 </header><!-- .entry-header -->

 <div class="entry-summary">
  <?php the_excerpt(); ?>
 </div><!-- .entry-summary -->

 <?php if ( 'post' == get_post_type() ) : ?>
NOTE: always take note of a reference from where the code was remove in order to rollback, just in case.

After this procedure, just the bold title shall appear.


No comments:

Post a Comment

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...