Forums › Forums › Search & Filter Pro › Adding post meta in search results
Tagged: customizing results
- This topic has 4 replies, 2 voices, and was last updated 9 years ago by Anonymous.
-
Anonymous(Private) November 22, 2015 at 10:49 pm #30447
I have customized the search results page to remove post summaries, by copying results.php into my theme template folder, and it’s working nicely. Now, I’d like to add a post meta field (“wp_review_total”) into the search results, so my display would look like:
the_title
** post-meta-field **
the_category
the_tagsIs this possible?
Ross Moderator(Private) November 23, 2015 at 9:05 am #30473Hey Ken
Do you mean so that you list the current selection for hte
wp_review_total
field at the top of hte saerch results template?Then you would look here:
http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/Or do you mean, you would like to display the value for
wp_review_total
in your template next to each result?Then you would need this:
https://developer.wordpress.org/reference/functions/get_post_meta/Thanks
Anonymous(Private) November 23, 2015 at 3:30 pm #30514It would be for each search result. I tried following the second example, but got empty results:
<?php $wp_review_total_values = get_post_meta( get_the_ID(), 'wp_review_total', true ); ?>
I’m not a PHP coder, so I’ll try playing with it some more. I may have missed something obvious.
Ross Moderator(Private) November 23, 2015 at 3:44 pm #30515Hey Ken
That looks like the right way to retrieve it – did you try echoing it out?
<?php $wp_review_total_values = get_post_meta( get_the_ID(), 'wp_review_total', true ); //echo out the values - should be ok because get_post_meta has the 3rd param set to true echo $wp_review_total_values; //alternatively dump the object to check whats inside: var_dump($wp_review_total_values); ?>
-
AuthorPosts