1

I have a custom Post Type I've created, and it also has some custom fields I created. For full disclosure, I used the Pods framework to do this.

The Post Type can be tagged using a custom taxonomy. When I visit the tag page for a given term in the taxonomy, e.g. mysite.com/my_taxonomy/term, the posts of Post Type show up as expected in an excerpt / teaser type of display.

What I would like to accomplish is to add my custom fields to this view. Right now the only field that shows up is the title, author, and date (there is no 'body' field). How can I add my custom fields to show up on this excerpt / teaser view of the content?

1
  • the first step is to found wich file of the theme is used. for that try the plugin "Query Monitor", it will show in the admin bar which templates are used and the order of search. wordpress.org/plugins/query-monitor
    – mmm
    Oct 31, 2017 at 21:45

1 Answer 1

1

The way to retreive some meta data is knowing the name of the custom field, for my example I will use: listing, property and address; normally this can be done after while (have_posts()) : the_post();

$listing = get_post_meta($post->ID, 'listing', true);
$property = get_post_meta($post->ID, 'property', true);
$address = get_post_meta($post->ID, 'address', true);

then you can print the output like echo $listing; according your needs.

2
  • Awesome, great concise answer, with all the parts I need, and none of the parts I don't. Was able to get it to work!
    – CHP
    Nov 1, 2017 at 9:19
  • For displaying custom taxonomy terms, replacing get_post_meta() with get_the_terms( $post->ID, 'taxonomy_name' ) works
    – CHP
    Nov 1, 2017 at 20:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.