0

Why can't I see the post content where as I can easily see the post title if I do a wordpress search. I have a custom post type "Artist" and I am using ACF.

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

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






           <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>' ); ?>

              </header><!-- .entry-header -->

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

             <footer class="entry-footer">
             <?php edigital_entry_footer(); ?>
             </footer><!-- .entry-footer -->
             </article><!-- #post-## -->
  • 3
    Please clarify your question... the_content is not part of acf. In fact there are no acf functions in the code provided. – gdaniel Aug 02 '17 at 18:32
  • I am using ACF and I have a custom post type "team". I have disabled all the post types from search results except "team". Now when I am performing a search for say "John". It is only displaying the title and permalink. I can't seem to be able to display the content under "John" – user3678230 Aug 02 '17 at 18:56
  • If the code you posted above is the search result page, then you need to follow @CKG example below and wrap your code in the wp loop. – gdaniel Aug 02 '17 at 19:02
  • I updated the above code. It still is showing just the title and permalinks – user3678230 Aug 02 '17 at 19:17
  • Hi @user3678230 Where do you do "I have disabled all the post types from search results except "team""? Sorry but I can't understand the problematic. – Jose Carlos Ramos Carmenates Aug 02 '17 at 20:26
  • ` function searchfilter($query) { if ($query->is_search && !is_admin() ) { $query->set('post_type',array('Artist')); } return $query; } add_filter('pre_get_posts','searchfilter'); ` – user3678230 Aug 02 '17 at 20:41
  • Hi Jose, I just added the above code in the functions.php file. now it will only display the 'artist' post type. – user3678230 Aug 02 '17 at 20:42
  • But still, I can't display the content – user3678230 Aug 02 '17 at 20:42
  • 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:21

1 Answers1

1

You need to put "the content" function call inside the WordPress loop in order for it to output your content to the page like the following.

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>

Hope that helps, Cheers!!!

Chandra Kumar
  • 4,127
  • 1
  • 17
  • 25