Skip Navigation

[Resolved] Query view based on url parameters

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 3 voices.

Last updated by Luo Yang 5 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1312989

Tell us what you are trying to do?
I'm trying to build a mini version of Google Ads in my site.

Is there any documentation that you are following?
I searched for 'match View results based on parameters of current page' but couldn't find anything.

Is there a similar example that we can see?
hidden link - Here you see this line above the search results: Automotive test ad IT test ad. These are 2 custom posts. I have a custom post type Professions too. And a post reference field Profession on the Ads custom post type.

Now i would like to show posts from the custom post type 'Ads' that have a match between this wpcf-job-profession url parameter and the post reference Profession of the ad. This makes the ad more relevant to the current page visited.

Thanks,
Menno

#1312995
#1313239

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I checked on your install and found that the filters you setup is using the custom plugin Search & Filter.

Now, the thing is that post reference field saves the related post ID as value. so, you should not use the URL param "Developer" test string, instead, you need to use the post ID.

When you check the professions post and check the ID of "Developer" post, the post ID is 15.

So, to your view, I changed the "Query Filte" as given under:

Filter by post relationship or repeatable fields group owner
Select posts in a Ad - Profession relationship that are related to the Post with ID set by the URL parameter _sfm_wpcf-job-profession.
eg. <em><u>hidden link</u></em>

Now, if you load the page, and pass the 15 which is "Developer" post ID, you will see the results.
hidden link

#1313251

Hi Minesh,

I just added a Views filter at the bottom of the sidebar but this also gives the page title as a parameter value: hidden link

The point is that the parameter value needs to be dynamic, not a static value.

#1314361

Minesh is on vacation, I will take care this thread.
I can log into your website, will update here if there is any found.

#1314365

Great thanks Luo. Yes please login :).

#1314403

As your request:
https://toolset.com/forums/topic/filter-view-by-text-instead-of-id/#post-1314401
please close the old ticket, then follow the new ticket