Skip Navigation

[Resolved] Filter view by text instead of ID

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 25 replies, has 2 voices.

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

Assisted by: Luo Yang.

Author
Posts
#1314217

Hi Toolset,

I would like to query posts in my view by url parameters, but not with the ID but the a text.

I created a view with 3 posts (ads) here: hidden link

As you can see it filters the posts but not the 3 ads at the top. When i go to here hidden link it works but doesn't show posts anymore (only ads).

Is it possible to filter a view by url parameter texts? Is it possible to refine the ads when a visitor clicks more filters?

Thanks,
Menno

#1314363

Dear Menno,

I assume we are talking about the same question as another thread:
https://toolset.com/forums/topic/query-view-based-on-url-parameters/

Please check the answer in above thread, and close this one.

#1314367

Yes it's the same question.

#1314399

So, which thread do you want me to answer? this new ticket or old ticket?

#1314401

This one is fine :).

#1314451

Here are what I found in your website:
1) The URL you mentioned above is archive page of post type "Jobs"
hidden link

2) You are using Views WordPress Archive "Archive - Job" to design above archive page:
hidden link

3) In above Views WordPress Archive "Archive - Job",
- in section "Query Filter", it is using below filter:
Select items with field:
Job - Profession is a string equal to URL_PARAM(wpv-wpcf-job-profession)
So the custom field "Job - Profession" is registered in post type "jobs"

- in section "Output Editor", there is a view's shortcode:
[wpv-view name="ads-serp"]

4) Above post view "Ads - SERP":
- Query "Ads" posts
- Filter by:
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. hidden link

I assume you are going to use custom field "Job - Profession" of "Jobs" post to filter another post type "Ads".

If it is, it is not possible within Views plugin yet, since there isn't field "Job - Profession" in post type "Ads", so it won't be able to work, and it is expected to display the result: No items found
hidden link

In my opinion, you might consider this:
1) Create another post view "related-ads-posts":
- Query ADs posts
- Filter by post type relationship between "Jobs" and "ADs" of The current post in the loop

2) Put above post view "related-ads-posts" insider loop of WordPress Archive "Archive - Job", so you will get some result like this:

- Jobs A
-- related ADs 1
-- related ADs 2
...
- Jobs B
-- related ADs 3
-- related ADs 4
...

More help:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

#1314455

Hi Luo,

Thanks for your response. I followed your steps but there no items show up yet: hidden link

This is the view: hidden link

Can you make some changes to let this work?

Thank you,
Menno

#1314461

Oh i see hidden link this looks great. But the ads are now between the posts and i would like to have 3 at the top like Google Ads.

#1314467

I have done below modifications in your website:
1) Edit the post view "Ads - Related post ads"
hidden link
in section "Query Filter", change the filter to:
Select posts in a Ad - Job post relationship that are a related to the current post in the loop.

2) Edit the WordPress Archive "Archive - Job":
hidden link
- in section "Loop item in Archive - Jobs", at the bottom, add above post view's shortcode:
[wpv-view name="ads-related-post-ads"]

- in section "Output Editor", remove above shortcode

3) Test it in front-end:
hidden link

You should be able to see the related ADs post

#1314469

As I mentioned above, you can display the result like this:
https://toolset.com/forums/topic/filter-view-by-text-instead-of-id/#post-1314451
- Jobs A
-- related ADs 1
-- related ADs 2
...
- Jobs B
-- related ADs 3
-- related ADs 4
...

Since there isn't field "Job - Profession" in post type "Ads", so that relationship filter won't work, hope it is clear.

#1314471

Yes this looks great but is there a way to bundle all related ads to three ads at the top?

#1314473

Is it possible to query posts that equal these 2 fields job-profession and ad-profession?

#1314475

I don't think there is such kind of built-in feature within Views plugin, you will need to consider custom codes, but according to our support policy, we don't provide custom codes support, you can check it with our Toolset Contractors:
https://toolset.com/contractors/

#1314477

Alright. Thanks for your support but this is not the way the ads should work. The ads now show up directly under the post.

I would to have it like Google Ads where there are 3-4 ads at the top (not between posts) that are related to the posts that are in the loop. I will take a look at the contractors page.

#1315147

OK, feel free to create new thread if there is new questions.