Home › Forums › Pro Support › Show Posts from a Category AND a Tag
- This topic has 7 replies, 2 voices, and was last updated 2 years, 9 months ago by
elvin.
-
AuthorPosts
-
February 12, 2021 at 12:54 pm #26687
Bizhan
ParticipantHello
I am using WP Show Posts ( Version 1.2.0-alpha.3 ) plus WP Show Posts Pro ( Version 1.0.0 )
I need to Show from Category AND related Tags, How is it possible.
I put Taxonomy post tag and checked all Terms but what can see in related posts is latest post and not filtered by tags.Regards
February 12, 2021 at 5:19 pm #26693Bizhan
ParticipantNeed to show related posts by Tags
February 15, 2021 at 5:38 pm #26833elvin
ModeratorHi there,
You can try this PHP snippet:
add_filter('wpsp_query_args',function( $args, $settings ){ if ( 1699 === (int) $settings['list_id'] ) { $args['tax_query'] = array( 'relation' => 'OR', array( 'taxonomy' => 'category', 'field' => 'slug', 'terms' => array( 'campaigns','project-updates' ), ), array( 'taxonomy' => 'post_tag', 'field' => 'slug', 'terms' => array( 'sample-tag-1' ), ), ); } return $args; },10,2);
Just make sure you change the values.
Replace
1699
with the ID of your WPSP list. Replace'campaigns'
and'project-updates'
with your category slugs and replace'sample-tag-1'
with your tag slug.February 16, 2021 at 3:04 pm #26888Bizhan
ParticipantWould you please tell me where/how should i put / use this PHP snippet ?
I intend to hook generate_before_comment_container / All PostsRegards
February 16, 2021 at 6:13 pm #26897elvin
ModeratorYou can place this PHP snippet on your child theme’s functions.php or through a Code snippets plugin.
Here’s how to add PHP: https://docs.generatepress.com/article/adding-php/
February 17, 2021 at 1:43 am #26911Bizhan
ParticipantHello
Thank you, What settings / config must be done in created Post List ? ( Post type : Post , Taxonomy : Category , Terms : Checked/selected all, …. ? )February 17, 2021 at 1:48 am #26914Bizhan
ParticipantI just need before comment container / In all Posts , Show 6 Related posts based on Tags in the post category. At this time GP Related Posts ( Version 1.3 ) doing it very well for me but i am interest do the same with Wpshowposts.
Regards
February 17, 2021 at 10:33 pm #26970elvin
ModeratorThank you, What settings / config must be done in created Post List ? ( Post type : Post , Taxonomy : Category , Terms : Checked/selected all, …. ? )
You don’t need to configure the post list if you’re going to use the snippet as the snippet will override the post tab’s settings.
I just need before comment container / In all Posts , Show 6 Related posts based on Tags in the post category. At this time GP Related Posts ( Version 1.3 ) doing it very well for me but i am interest do the same with Wpshowposts.
I’m not sure I understand what you mean.
Are you asking how to insert the WP Show Post before the comment container? I believe you can use GeneratePress’ hooks for that. You can open up a new topic on its support forum to ask how. https://generatepress.com/forums/forum/general-support/
-
AuthorPosts
- You must be logged in to reply to this topic.