Forums › Forums › Search & Filter Pro › How to display taxonomies in post feed results using the short code.
- This topic has 3 replies, 2 voices, and was last updated 5 years, 11 months ago by
Trevor.
-
Trevor(Private) March 20, 2019 at 11:25 am #205697
If you are using our shortcode display results method, it uses our exemplar template – results.php. The basic steps for customising the file are set here, but you would need to do the coding:
https://searchandfilter.com/documentation/search-results/using-a-shortcode/#customising-the-results
This is a good answer on how to show the terms:
https://wordpress.stackexchange.com/questions/10175/how-to-display-custom-taxonomies-in-posts
But, where they use
$post->ID
, use insteadget_the_ID()
Anonymous(Private) March 20, 2019 at 1:55 pm #205727Here is the code that I added to the results.php file:
<div>
<h2>“><?php the_title(); ?></h2><p><br /><?php the_excerpt(); ?></p>
<?php
if ( has_post_thumbnail() ) {
echo ‘<p>’;
the_post_thumbnail(“small”);
echo ‘</p>’;
}
?>
<p><?php the_category(); ?></p>
<p><?php the_tags(); ?></p>
<p><small><?php the_date(); ?></small></p>
<p><?php get_the_ID(); ?></p>
</div>However, it still is not displaying the taxonomies.
Trevor(Private) March 20, 2019 at 2:14 pm #205735<p>><?php get_the_ID();?></p>
on its own won’t do it.You would need something like this instead:
<ul><?php echo get_the_term_list( get_the_ID(), 'jobs', '<li class="jobs_item">', ', ', '</li>' ) ?></ul>
Where the name of the taxonomy is
jobs
(so you replace that with your own). A CSS class is there so you can style it, but obviously you can rename that to suit.This code makes a standard ‘list’.
-
AuthorPosts