Recent Post Looper Provider

Hi Theme.co Team,

I’ve got some feature requests. It would be beneficial if the Recent Post Looper Provider allowed for the inclusion and/or exclusion of specific taxonomy terms, similar to what is available in the Query Builder. Another option could be that the Query Builder would allow leave out the current post from the looper output, like in the Recent Post Looper Provider.

If there is a workaround for that currently, please direct me in the right direction. Let’s say we need to display recent posts that belong exclusively to the video taxonomy term but exclude currently viewed post on single post layout page. Should that be achieved through the Query String? If so, how can I exclude the current post? It would be useful if you could make a video and/or manual on how to constract Query Strings correctly. This may specifically apply to the Max Super Loopers subscription, if not to everyone else.

Thank you for your continued support. You are the best of the best.

1 Like

Hello John,

Thanks for writing to us.

Thanks for your feedback. I would suggest adding this query string to display posts from the category and exclude the current post.

post_type=post&posts_per_page=5&post__not_in%5B0%5D={{dc:post:id}}&tax_query%5B0%5D%5Btaxonomy%5D=category&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D=video

Hope it helps
Thanks

Thanks @prakash_s,

And which key should be added if we exclude some terms from the post taxonomy in the loop output? Let’s keep it simple. We’ll use your example, but this time we will leave out all video posts from the loop. To understand better how a query works.

Hello John,

For easier troubleshooting, always define the query argument. For example:

array(
'post_type' => 'post',
'post__not_in' => array(
    '{{dc:post:id}}'  // Exclude current post (optional)
),
'tax_query' => array(
    array(
        'taxonomy' => 'category',
        'field'    => 'slug',
        'terms'    => 'video',  // term slug to exclude
        'operator' => 'NOT IN'  // <--- THIS IS THE KEY!
    )
),
'orderby' => 'date',
'order'   => 'DESC'

);

And this will give out:

Hope this helps.

And this will give out:
post_type=post&post__not_in%5B0%5D={{dc:post:id}}&tax_query%5B0%5D%5Btaxonomy%5D=category&tax_query%5B0%5D%5Bfield%5D=slug&tax_query%5B0%5D%5Bterms%5D=video&tax_query%5B0%5D%5Boperator%5D=NOT%20IN&orderby=date&order=DESC

@ruenel and @prakash_s thank you very much for your explanations with examples.

This is a good starting point for grasping how query strings are constructed.

I appreciate your help as always.

You are most welcome, John.

I am sorry to bother again but I’ve got additional questions on the topic.

  1. I test your examples in different scenarios and can’t understand how to limit taxonomy terms just to those that exist in the current post. For example, if we use a query string for the post terms looper provider and we need to leave out empty terms, just like the All Terms predefined Looper Option does. How can it be achieved with the query?

  2. I am also thinking about making a Related Posts block Looper Provider that will show posts with the same taxonomy terms as the current post. I suppose that the main difficulty here will be to get more than one term applied to the post being viewed. I guess a few term parameters should be specified for each of those. But that should be possible with TWIG I guess.

Interesting topic that truly deserves to be included in Max Super Loopers course. Practical enhancement of PRO capabilities. This is a kind of strange to have a powerhouse which you are capable to use only on 50-60%.

Hello John,

1.) You cannot use a query string to get the taxonomy terms. You may need to use the Looper Provider Custom for that. Check out these related threads:

If you need the post items to be in the same terms, you will have to run a Looper Provider Current Terms first, then use the very first term in your next Looper Provider Query String. Sample Structure would be like this:

    Looper Provider Current Post Term
      Looper Consumer [display only one] (will be getting the first term only)

       Looper Provider Query String
             Looper Consumer

                  Display post item

Sample Query Argument would be:

2.) The above example is already for related post items with the same terms.

Best Regards.

Sample Argument:

array(
	'post_type' => 'post',
	'post__not_in' => array(
	    ' dc:post:id '  // Exclude current post (optional)
	),
	'tax_query' => array(
	    array(
	        'taxonomy' => 'category',
	        'field'    => 'slug',
	        'terms'    => '{{dc:term:slug}}',  // this will be from the parent Looper Provider Current Post Term
	        'operator' => 'IN'  // Only items with the same term will be returned
	    )
	),
	'orderby' => 'date',
	'order'   => 'DESC'
);

(Kindly add the open and close curly braces for the post id and the term slug dynamic content)

Thanks a lot, @ruenel.

Will investigate that further for sure.

You are most welcome, John.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.