Note that there are some explanatory texts on larger screens.

plurals
  1. POWordpress: Include custom_fields (Book author) in search results
    primarykey
    data
    text
    <p>I am using TwentyEleven as my base theme which I have skinned. In my Content.php file, the search results looks something like this </p> <pre><code>&lt;?php if ( is_search() ) : // Only display Excerpts for Search ?&gt; &lt;div class="entry-summary"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt;&lt;!-- .entry-summary --&gt; &lt;?php else : ?&gt; &lt;div class="entry-content"&gt; &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyeleven' ) ); ?&gt; &lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link"&gt;&lt;span&gt;' . __( 'Pages:', 'twentyeleven' ) . '&lt;/span&gt;', 'after' =&gt; '&lt;/div&gt;' ) ); ?&gt; &lt;/div&gt;&lt;!-- .entry-content --&gt; &lt;?php endif; ?&gt; </code></pre> <p>I am trying to pull the "Author" Meta key/value pairs to return in my search results along with the Post Title and Post Content like so:</p> <pre><code>&lt;?php if ( is_search() ) : // Only display Excerpts for Search ?&gt; &lt;div class="entry-summary"&gt; &lt;?php the_excerpt(); ?&gt; &lt;/div&gt;&lt;!-- .entry-summary --&gt; &lt;?php else : ?&gt; &lt;div class="entry-content"&gt; &lt;?php the_content( __( 'Continue reading &lt;span class="meta-nav"&gt;&amp;rarr;&lt;/span&gt;', 'twentyeleven' ) ); ?&gt; &lt;?php get_post_meta(get_the_ID(), _wpsc_author, true); ?&gt; &lt;?php wp_link_pages( array( 'before' =&gt; '&lt;div class="page-link"&gt;&lt;span&gt;' . __( 'Pages:', 'twentyeleven' ) . '&lt;/span&gt;', 'after' =&gt; '&lt;/div&gt;' ) ); ?&gt; &lt;/div&gt;&lt;!-- .entry-content --&gt; &lt;?php endif; ?&gt; </code></pre> <p>Note the line: </p> <pre><code>&lt;?php get_post_meta(get_the_ID(), _wpsc_author, true); ?&gt; </code></pre> <p>Yet, this returns nothing?</p> <p>I have read a fair amount on the topic of the_meta(), get_post_custom() etc, but nothing I am trying seems to have worked.</p> <p>Would appreciate some insight?</p> <p><strong>EDIT:</strong> Apologies, I wasn't too clear about the "Author" part. Author is a custom field in the post_meta table along with "book type", book condition" published year" etc. It is not the Post Author.</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload