Condition to hide element based on part of url

Hello,

I tried different combinations and suggestions from other topics but I cannot hide an element if there is a specific part in URL.

For example, if URL is domain/shop/?wpf=wpf_66827c77d7fd4&wpf_page=1 it would be great if I could target only ?wpf or just wpf because every filter URL have that.

Can you point me how to achieve this?

Best regards,

Ofir

Hey Ofir,

Yes, that’s possible. In your Element Condition, select Number then insert this Dynamic Content {{dc:url:param key="show"}}. Set the operator to == then set the value to 1.

image

Now, if the URL has ?show=1 Query String, it will display your element.

image

Hello,

this could work. Just additional question. How to make it opposite? It seems != condition don’t apply.

Best regards

Hey Ofir,

You can try to change the condition, try this one 1 != {{dc:url:param key="show"}}.

Hope that helps and let us know how it goes.

Hello,

Unfortunately, it didn’t work. Could that be because the website is on a development domain and inside a folder, which caused the problem?

Because the link is devdoman/folder/shop/?wpf=wpf_66827c77d7fd4&wpf_page=1…?

That would change when the site goes live and it will be in public_html root.

Best regards,

Ofir

Hello Ofir,

If your URL is domain/shop/?wpf=wpf_66827c77d7fd4&wpf_page=1, the condition will be: {{dc:url:param key="wpf_page"}} == 1 or 1 == {{dc:url:param key="wpf_page"}}. This means that the element will only display when the condition is true. If you are already using this statement, please provide us with your WP access so we can check.

Thanks.

Hello again,

1 == {{dc:url:param key="wpf_page"}} this worked but only for the first page of filter display.

Can you please explain why wpf_page works but if it is only wpf key, then it won’t. Because, if I switch to another page with filter pagination, the condition stops working and the element shows again.

Best regards,

Ofir

Hey Ofir,

If you check your URL domain/shop/?wpf=wpf_66827c77d7fd4&wpf_page=1

there are 2 parameters wpf and wpf_page

wpf = wpf_66827c77d7fd4
wpf_page = 1

Given the details above, the wpf_page works because the value is 1. If you want to use the wpf parameter, the value should be wpf_66827c77d7fd4.

Hope that helps.

Hello,

just to say this one is worked for my case:

string: {{dc:url:param key=“wpf”}} is not wpf_66827c77d7fd4

Now theme pagination shows only on shop page and when filter link active, pagination is hidden.

Hey Ofir,

That’s great and for {{dc:url:param key="wpf"}}, you should use the string because it is comparing string data.

Thank you.

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