Looper and dynamic url?

Dear Team,

I am searching for a solution, where different terminals see different content. I am thinking about using categories for the terminals and additionally tags for sorting the content. No idea, if this will ever become a working solution.

I know, I can use category and tags to query the content:
http://mydomain.com/category/terminal01/?tag=mytag

first step should be permanent sending the terminal name as category from the corresponding terminal. I believe I could do this via function.php (http://…/?category=terminal01)

second: I need to sort the content via looper. But unfortunately the looper did not know, which terminal is asking for content. I should be able to extract the category name from the dynamic url (e.g. http://mydomain.com/news?category=terminal01) and use it in the WP query of the looper provider.
Possible and ny ideas how to do so?

thank you,
Michael

Hello Michael,

Thanks for writing in!

Please be advised that the categories and the tags have their own archive URLs.
For example:

http://example.com/category/category-name-a
http://example.com/category/category-name-b
http://example.com/category/category-name-c

http://example.com/tag/tag-name-a
http://example.com/tag/tag-name-b
http://example.com/tag/tag-name-c

You can always create a custom archive layout that will display the post items related to the category or tag. Regretfully there is no feature in the theme that allows you to create a sort filter button within the archive page. What you are trying to do may only be possible with custom development which is far beyond the scope of our support already.

Thank you for your understanding.

Hi @ruenel,

thank you for your answer.
It is possible to sort with categories AND tags at the same time (also with logical operators) like:
AND:
http://mydomain.com/category/mycategory/?tag=mytag1+mytag2
OR:
http://mydomain.com/category/mycategory/?tag=mytag1,mytag2

What I need is to dynamically send the name of the category “mycategory” and use this in the looper.
Is there a hook to send the looper a value outside the original drop down?
If so, I could script a few lines, which will send the values for the category to the looper.

add_filter(‘xyz’, function(){
some magic
});

or

do_action

Thank you,
Michael

1 Like

Hey Michael,

I’m sorry but I’m not entirely sure what you wish to achieve. As far as I understand, you want to display products based on category and tag. You can display products in a custom archive using the Query Builder Looper Provider. You can use Product Categories and Product Tags in there.

image

image

Hope that helps.

Hi there,

I want to go further.
What you are showing is the normal behavior of loopers.
Now think about this:

Looper Provider Query Builder is not using internal taxonomes.
I want to overhand variables from a dynamic url.
E.G.: Mysite.com/products?product=Hoodies

Looper will not use a fixed taxonomy, instead it will use the dynamic value. This is of course a tag or category. However, it is not fixed named in the Looper like “Hoodies”. Looper is “listening” if there is a parameter in the url.

Howdy, @mickna! Thanks for writing in…what you are attempting to do is not currently possible in the Query Builder as we don’t support Dynamic Content in those parameters. This is a very advanced implementation you are trying to get setup, and as such falls more into a custom development camp that you will need to work on getting wired up. That being said, I’d like to provide you with some assets that may help point you in the right direction.

Firstly, while you can’t do this directly in the Query Builder, you should be able to achieve something via the Query String provider type, as this gives you full access to the WP_Query class, you just have to set everything up yourself. It seems like you are already fairly well versed in what you’re looking to accomplish, but if you have not reviewed the WP_Query documentation in a while, please do so here:

Next, coding a query string by hand is quite cumbersome, so you’ll need a method for generating one based out of the information you’re trying to pass in. I explored this a while back with another customer and informed them on the specific steps I used to craft a query string they needed with the following resource. Please review this to see how those can be generated:

You will need to read through the WP_Query documentation to find the parameters you need to get your setup working, but once you craft your information using the steps outlined there and pass it into http_build_query(), you should get a working query string.

Now the one nuance here is that you’re also trying to create WP_Query string that references a literal query string in your URL. To do that, you will need the {{dc:url:param}} Dynamic Content string, which you can then pass a key into with the parameter you’re trying to reference in the URL. So, for example, if I wanted to access a query string called “banana” in my URL, you would use {{dc:url:param key="banana"}}. Then whatever that value is in the URL bar, you will be able to access it like so:

Now to actually reference a Dynamic Content string within your WP_Query string, there is a little bit of a nuance to get that working, but I actually explored that with another user here:

If you read through my comments there, you’ll see how I included the Dynamic Content string in the query and had to do a little bit of manual formatting after running it through http_build_query() to get it working.

All of that should get you pointed in the right direction to get something like this working. As mentioned above, this is a highly custom implementation, which will need to be wired up on your end as it’s very unique to your setup, but it should be possible via the Query String Provider Type.

Cheers!

Hello @kory,

wow! Thank you so much for your help.
I have to go through your tips these days, but I need to say thank you just now. This is awesome.

Michael

Hi Michael,

You’re welcome and it’s our pleasure to help you. If you have any other concerns regarding our theme features, feel free to reach us.

Thank you.

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