We're merging with GenerateBlocks! Learn more here.

[Support request] Show Posts from a Category AND a Tag

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Show Posts from a Category AND a Tag

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #26687
    Bizhan
    Participant

    Hello
    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

    #26693
    Bizhan
    Participant

    Need to show related posts by Tags

    #26833
    elvin
    Moderator

    Hi 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.

    #26888
    Bizhan
    Participant

    Would you please tell me where/how should i put / use this PHP snippet ?
    I intend to hook generate_before_comment_container / All Posts

    Regards

    #26897
    elvin
    Moderator

    You 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/

    #26911
    Bizhan
    Participant

    Hello
    Thank you, What settings / config must be done in created Post List ? ( Post type : Post , Taxonomy : Category , Terms : Checked/selected all, …. ? )

    #26914
    Bizhan
    Participant

    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.

    Regards

    #26970
    elvin
    Moderator

    Thank 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/

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.