[Support request] Related Posts

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Related Posts

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27126
    Bizhan
    Participant

    Hello
    I am trying to show tags of the same category under each post. In other words, all the posts shown under a blog post should have the same tag but also belong to the same category as the shown post.
    I am using generatepress theme.

    Regards

    #27128
    elvin
    Moderator

    Hi there,

    I’m not sure what the goal is. I believe you’re asked something similar here? https://wpshowposts.com/support/topic/show-posts-from-a-category-and-a-tag-2/#post-26687

    Can you explain a bit more how it should differ? Also, are you asking for the theme’s blog post lists or still on WPSP plugin? Let us know.

    #27280
    Bizhan
    Participant

    Hello
    I made a post list in wp-show-posts, called Raleted posts. Using the shortcode of this post list and using Elements-hock in generate_before_commen, I want to add related posts so the last 6 posts in the same category as the displayed post are displayed. Currently, using gp_related_posts plugin and bu setting filter by tags or category, I can display related tags but I want to display the shortcode in the desired place.

    Regards

    #27287
    elvin
    Moderator

    You can try this PHP snippet on your GP Hook. Make sure Execute PHP is enabled.

    <?php
    
    function wpsp_terms(){
    	
    	$post_info = get_queried_object();
    	$categories = get_the_category($post_info->ID);
    	$tax_term = array();
    	if( !empty($categories) ){
    		foreach( $categories as $category ) {
    				$tax_term[] = $category->slug;
    		}
    	}
    	return $tax_term;
    }
    
    var_dump(wpsp_terms());
    
        $settings = array(
            'taxonomy' => 'category',
            'tax_term' => wpsp_terms(),
        );
    
        wpsp_display( 1699, $settings );
    
    ?>
    

    Note: If there’s only 1 post on the category. Nothing will display because there’s no sibling posts within that category.

    • This reply was modified 1 week, 1 day ago by elvin.
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.