- This topic has 27 replies, 4 voices, and was last updated 2 years, 10 months ago by Tom.
-
AuthorPosts
-
May 17, 2021 at 8:18 am #1784839TomLead DeveloperLead Developer
Can you try the updated second function?
May 19, 2021 at 12:51 am #1789145NemanjaHi Tom,
I tried the updated function, posts are now displayed correctly but they are still duplicated.
Link below.
May 19, 2021 at 9:33 am #1790082TomLead DeveloperLead DeveloperAha, 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?
May 21, 2021 at 2:39 am #1792296NemanjaHi 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.
May 21, 2021 at 8:06 am #1792869TomLead DeveloperLead DeveloperYou can use the
author
parameter in the shortcode which accepts the author ID: https://developer.wordpress.org/reference/classes/wp_query/#author-parametersYou may need some additional PHP if you’re wanting to get that author ID dynamically.
May 23, 2021 at 7:04 am #1794951NemanjaHi 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!
May 24, 2021 at 9:07 am #1796293TomLead DeveloperLead DeveloperWhere would the ID come from? Is this for an author archive page?
May 24, 2021 at 9:54 am #1796366NemanjaMaybe 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)
May 25, 2021 at 8:16 am #1797620TomLead DeveloperLead DeveloperThis 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;
May 27, 2021 at 11:29 pm #1801026NemanjaHi Tom,
I don’t understand where to put that code, can you please be more specific?Thank you so much for your time.
May 28, 2021 at 7:58 am #1801782TomLead DeveloperLead DeveloperThe 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.June 1, 2021 at 11:23 am #1806338NemanjaHi Tom,
I found another way to display those posts with CSS.Thank you so much for your time and help.
You guys are great !!June 2, 2021 at 9:20 am #1807592TomLead DeveloperLead DeveloperNo problem! 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.