Archived topic
Display posts from a taxonomy & a specific term from a custom taxonomy
17 replies · Started by webcréateur on September 19, 2019
In your post here: https://generatepress.com/forums/topic/display-posts-from-a-taxonomy-a-specific-term-from-a-custom-taxonomy/#post-1015127
You have a bunch of wpsp_display() functions.
What if you did this?:
wpsp_display( 38852, array( 'tax_term' => 'your-term-name' ) )
So each function call has a different term name set.
I was not able to find a workaround like the suggestion in your last post.
We have to output posts in a loop sorted by category on archive page of a custom taxonomy.
I was able to output the correct posts in a loop like:
<!-- Start the Loop. -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- Test if the current post is in category 534. -->
<!-- If it is, the div box is given the CSS class "post-cat-three". -->
<!-- Otherwise, the div box is given the display:none. -->
<?php if ( in_category( '534' ) ) : ?>
<div class="post-cat-three">
<?php else : ?>
<div style="display:none;">
<?php endif; ?>
<!-- Display the Title as a link to the Post's permalink. -->
<?php echo get_secondary_title(); ?>
<h2><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
</div> <!-- closes the first div box -->
<!-- Stop The Loop (but note the "else:" - see next line). -->
<?php endwhile; else : ?>
<!-- The very first "if" tested to see if there were any Posts to -->
<!-- display. This "else" part tells what do if there weren't any. -->
<p><?php esc_html_e( 'Sorry, no posts matched your criteria.' ); ?></p>
<!-- REALLY stop The Loop. -->
<?php endif; ?>
The loop outputs only relevant posts from one category and hides via css all other categories.
This seems to work well.
Can we do the same in WPSP?
I don't think that's possible with WPSP. You shouldn't actually need WPSP if you have the loop working like that.