Relevanssi - A Better Search
Custom Field Excerpt/Content not showing (2 posts)

  1. roothost
    Posted 3 years ago #

    Having spent the last 2 days on this, and having tried every single plugin available I am well and truly stumped!!

    I have a site that relies very heavily on custom fields (using the advanced custom field) plugin. Now I need to have a search function on the site that, when a term is entered, outputs all results from anywhere on the site (static pages, posts, custom fields etc).

    Currently, my output code is this, which returns the title and date/time fine, but just gives me "..." instead of any actual content?

    <? if(have_posts()): ?>
      <? while(have_posts()): ?>
        <? the_post() ?>
        <p><? the_time('F j, Y') ?> at <? the_time(); ?> by <? the_author_link(); ?></p>
        <p><?php relevanssi_the_excerpt(); ?></p>
       <? endwhile; ?>
    <? endif; ?>


  2. Mikko Saari
    Plugin Author

    Posted 3 years ago #

    You need to do some custom programming to get custom fields showing in the excerpt. Use the relevanssi_excerpt_content filter to add the custom field content to the post content (just concatenate it to the end). The filter filters the post content, and has two parameters, the $post object (so you can get the $post->ID) and the query.

    Also, just use the_excerpt() instead of relevanssi_the_excerpt(), that should not be necessary.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic