Forums Forums Search & Filter Pro How to display taxonomies in post feed results using the short code.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #205659

    Hello,

    How would I display the custom taxonomies in the post results? Kind of like tags to the individual post.

    Trevor
    #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 instead get_the_ID()

    Anonymous
    #205727

    Here 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
    #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’.

Viewing 4 posts - 1 through 4 (of 4 total)