Archived topic
Custom category archive page
27 replies · Started by Nemanja on May 6, 2021
Can you try the updated second function?
Hi Tom,
I tried the updated function, posts are now displayed correctly but they are still duplicated.
Link below.
Aha, that makes sense. The archive query is built before WPSP is rendered, so it's not aware of the posts that WPSP is going to display yet.
Hmm, tough one. We would need a way to know which posts WPSP will be showing before it's actually rendered. Maybe they're in a specific category? A set list of IDs?
Hi Tom,
thank you for your quick response.
I have put both WPSP lists inside block-hook element and hooked them inside container, and than removed (.generate-columns-container{display:none}) default WP posts. So it works as it should now.
But now I can't display posts by author. Is there any similar shortcode ( [wp_show_posts id=”123″ settings=”taxonomy=category&tax_term=current”] ) I can use, so i can display posts by author??
Thank you so much for your time.
You can use the author parameter in the shortcode which accepts the author ID: https://developer.wordpress.org/reference/classes/wp_query/#author-parameters
You may need some additional PHP if you're wanting to get that author ID dynamically.
Hi Tom,
Yes , I need that snippet because I want to get that ID dynamically.
So please if you can sand me that I would be grateful.
Thank you!
Where would the ID come from? Is this for an author archive page?
Maybe it can take name of an author from link and yes it is for an author archive page.
Link below.(currently showing WPSP list with specified author ID)
This might help: https://wordpress.stackexchange.com/questions/35249/echo-author-id-in-author-php
I would try this one:
$author = get_queried_object();
$author_id = $author->ID;
Hi Tom,
I don't understand where to put that code, can you please be more specific?
Thank you so much for your time.
The first thing to do would be to install this version of WPSP: https://wpshowposts.com/wp-show-posts-1-2-0/
Then, you could try this filter:
add_filter( 'wpsp_query_args', function( $args, $settings ) {
if ( 123 === (int) $settings['list_id'] && is_author() ) {
$author = get_queried_object();
$args['author'] = $author->ID;
}
return $args;
}, 10, 2 );
You'll just need to update 123 with the ID of the list you're targeting.
Hi Tom,
I found another way to display those posts with CSS.
Thank you so much for your time and help.
You guys are great !!
No problem! :)