3

Image says it all... Page Edit:

enter image description here

Search Results:

enter image description here

functions.php to enable page excerpts

add_post_type_support( 'page', 'excerpt' );

search.php code for displaying excerpt

<?php the_excerpt(); ?>
<!-- tried <?php echo get_the_excerpt();?> too -->

Full search.php code

<?php
/**
 * The template for displaying Search Results pages.
 *
 * @package Shape
 * @since Shape 1.0
 */

get_header(); 
get_template_part('inc/header-image');?>


<div class='wrapper'>
    <div class='container main'>
        <div class='post-area grid_9'>
            <div class='posts-container'>
                <header class="page-header">
                    <h1 class="page-title"><?php printf( __( 'Resultados da Busca' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
                    <input type="search" value="<?php printf( __( '%s' ), '' . get_search_query() . '' ); ?>"></input>
                </header><!-- .page-header -->
                <div class="linha-horizontal"></div>
                <?php while (have_posts()) : the_post(); ?>
                    <div class="post-entry clearfix"> <!-- Main wrapper -->
                        <div class="post-entry-content"> <!-- Post-entry-content -->
                                <h2><a class="search-item-title" href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
                                        <?php the_excerpt(); ?>
                                        <a href="<?php the_permalink(' ') ?>" class="post-entry-read-more" title="<?php the_title(); ?>"><?php the_permalink(' ') ?></a>
                                        <div class="linha-horizontal search-divider"></div>
                        </div><!-- END of post-entry-content -->
                    </div><!--End of main wrapper -->
                    <?php endwhile; ?>

            </div>
        </div>
    </div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
1

You're confusing "post type support" - which means enabling "feature" (and therefore MetaBoxes) for a post - with templating.

  1. Go into your theme, search for the search.php template in the folder.
  2. Add a Child Theme
  3. Add a file named search.php to your Child theme and copy/paste the content of your parent themes template file in there.
  4. Exchange the_content() with the_excerpt()

Keep in mind that this can highly differ from theme to theme. Some themes use "Template Parts" to add parts to build a template. Others use "Conditional Tags" to switch between parts in their code in fallback template files of the "Template Hierarchy" and others use filters or hooks to alter the output in a template.

Note: This answer is meant as a guide, not a copy/paste solution as the solution can highly differ from theme to theme.

  • Hmm, I'm not very confident this will work, as you can see I'm not using the_content(), but the_excerpt() already, the only difference I see is that it will go under a child theme... Will it make any difference? – Lucas Bustamante Oct 27 '13 at 20:00
  • I've made more tests, the only pages with post_excerpt content on the database are those whose I've entered manually. All other are empty (and they output content instead). See Image for post_excerpt content in PHPMyAdmin - What's wrong then? – Lucas Bustamante Oct 28 '13 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.