0

I have a custom post type "Team Members". Right now If I type a team members name, it is just showing me the title of all the pages that contain How can I make it to search the content and not just the title

For example:- Team Member is John and the content is "John is bla bla bla, John is bla bla.

Now if I type john in the search bar, it should display all the john and not just the title

       <?php
    if ( have_posts() ) : ?>

        <?php
        /* Start the Loop */
        while ( have_posts() ) : the_post();

            /**
             * Run the loop for the search to output the results.
             * If you want to overload this in a child theme then include a file
             * called content-search.php and that will be used instead.
             */
            get_template_part( 'template-parts/content', 'search' );

        endwhile;

        the_posts_navigation();

    else :

        get_template_part( 'template-parts/content', 'none' );

    endif; ?>

The search content is setup as follows"-

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

    <?php if ( 'Artist' === get_post_type() ) : ?>
    <div class="entry-meta">
        <?php edigital_posted_on(); ?>
    </div><!-- .entry-meta -->
    <?php endif; ?>
</header><!-- .entry-header -->

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

<footer class="entry-footer">
    <?php edigital_entry_footer(); ?>
</footer><!-- .entry-footer -->

  • Is your search finding all the posts that contain "john" correctly and the problem is that the content text is not displaying on the search page? – Andrew M Aug 03 '17 at 09:18
  • Yes. Right now it is displaying titles of all the team members page, that contain the word john. I want to display the content as well and not just the page title. – user3678230 Aug 03 '17 at 13:42
  • Ok. can you try one thing. Remove the_excerpt(); and replace it with the_content(); - that should sort out the problem – Andrew M Aug 03 '17 at 13:53
  • Tried that before as well. Still, just the title and the permalink. No sign of the content. Shaking My Head – user3678230 Aug 03 '17 at 14:05
  • Alright, the only thing I can think of is to make sure the posts have content or are you storing the content differently for this custom post type? – Andrew M Aug 03 '17 at 15:07
  • It has its own content. Each custom type has its own content. – user3678230 Aug 03 '17 at 15:29
  • Possible duplicate of [Add ACF fields to search results page WordPress](https://stackoverflow.com/questions/36787391/add-acf-fields-to-search-results-page-wordpress) – FluffyKitten Aug 08 '17 at 04:20

0 Answers0