Query string by shortcode

Hi,
on the page https://www.ciociariaecucina.cloud/blog/nuovo-presidente-dellaccademia-delle-belle-arti-di-frosinone/ (in the final section) I’m trying to make a query string that filters the data through a shortcode but I am not able.

I’ll explain.
Inside functions.php I created a shortcode called [breadcrumb] that extrapolates the name of the category to which my article belongs (in the example, the category is “Cultura”).
The shortcode works because if I enter it in a text field I get the right result:

But if within the looper I wanted to display the articles belonging to the “Culture” category using this expression it does not work:
3

Instead if I write:
category_name=[breadcrumb]
it works:

How can I go about solving?
I hope I was clear

Hello @scenaryo,

Thanks for writing to us.

It seems that you want to display the posts from the current post category, I would suggest you please have a look at this thread for reference. Please note shortcode works on Text and Raw content elements.

Hope it helps
Thanks

Hi @prakash_s,
thanx but the solution you suggest me is ok for categories but not for subcategories.
In my case I have a main category called “Blog” and a series of sub-categories (“Cultura”, Mondo Vino", etc.).
How can I solve?
Thanx

Hey @scenaryo,

Would you mind sharing your credentials so that we can check your setup properly? To do that, please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password
  • Page URL or Layout Builder Name

You can find the Secure Note button at the bottom of your posts.

Thank you.

Hi @marc_a,
I send you the credentials.
The problem is inside the section called “Cultura” which is inside the “dettaglio - BLOG” Layout.
Thank you very much

Hey @scenaryo,

I’ve asked one of our developers and the shortcode doesn’t work with Query String. It is advisable to use the custom looper provider then inside the custom code you need to add a query to get the current post categeory.

Thank you.

Hi @marc_a,
thanx, I understand.
And how can I get the current post category?
If I use {{dc: term: name}} I get “Blog” which is the macro category, but I am interested in the sub-categories of “Blog”, for example “Cultura”…

Hello @scenaryo,

Are you trying to display related post items in your custom Single layout? Perhaps, these old threads can help you instead:

Best Regards.

Hi @ruenel,
i have read these old threads but they don’t help me.
I want to display related post items in my custom Single layout filtered by the sub-category (not the category) of the current post.

So, for example, if I’m viewing a post from the “Blog> Cultura” sub-category, I want to display, in the bottom of the page, 3 more posts belonging to the same sub-category.

Thanx

Hey @scenaryo,

We apologize for the incomplete answers.

You previously said that if you use {{dc: term: name}}, you get the Blog. That is because that DC will only get the 1st category you assigned to your post. Uncheck the Blog category from your post and see the result.

image

I did a test in my site and {{dc: term: name}} works together with the post__not_in parameter to exclude the current post. Your whole Query String should look like the code below.

category_name={{dc:term:name}}&post__not_in%5B0%5D={{dc:post:id}}

If you want to show multiple categories, that would require a complex looper or even a custom looper and we can’t handle that as part of theme support as custom coding and testing would be required for that.

If you’re interested in pursuing multiple categories, you might want to have our Elite team to the work for you. You can check the service here https://theme.co/elite

Hope that helps.

Hi @christian,
I solved unckecking the Blog category: thank you very much!

Hey @scenaryo,

We’re glad that my colleague was able to help you with your issue! If you have any other concerns or clarifications regarding our theme features, feel free to open up a new thread.

Thank you.

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