Skip Navigation

[Resolved] Linking for a custom taxonomy value to a custom search page

This support ticket is created 4 years, 7 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 9 replies, has 2 voices.

Last updated by donC-3 4 years, 7 months ago.

Assisted by: Beda.

Author
Posts
#1600121

We have a custom post type and showing it's content on a page like hidden link

What we want to do is take the custom fields and the tags and make them clickable, when clicked they would link to hidden link and auto populate the search field (so if someone clicks on a tag Mountain it would go to search looking for Mountain tagged items). Make sense?

I can probably figure out how to make the links but how do I pass that in to the search page automatically ? Is there a parameter I can set? Trying to avoid custom javascript on the page if there's something built in.

#1600535

To pass the clicked values to the View as a search you'd have to ensure the View has Query Filters that listen to "URL parameters".

Then, copy those URL parameters (generally, that is the part after ? in a WordPress Query URL, like in ?post=1, "post" is the URL parameter)
In Views Queries, you can set these parameters for each field of which you want to use for the View's filtering, and you can customize them as well.

These URL parameters must be added to the Link where you want to click, so when clicked, it leads to the page, appending all the URL parameters so the viewer can read them and return the adequate results

The Link has a static and a dynamic part, so likely the easiest to use is a Text and Fields Block.
In HTML mode, add links shown in this pseudo code:

<a href="site.com/page/?url_param_one=[your_shortcode_to_display_field_value]&your_other_url_param=[another_field_shortcode]&another_url_param_etc=[one_more_field]"

You CAN actually also insert ShortCodes like above example directly in a Button Link of a Button Block like seen in my screenshot.
However, I think it's easier to maintain in an HTML editor if you are comfortable with a little HTML.

A tip:
If your shortcodes have attributes, it will have apostrophes, and then do NOT use "double quotes, but single: ' for your attributes, this will avoid your links HTML to break.

#1600741

Thanks. I will give this a go.

#1601071
Annotation 2020-04-25 161750.png

ok, I tried and failing. Here's a url to a quick view i set up with filters.

hidden link

I've attached an image of the query filter (only one on the view). What am I missing? Probably something stupid and small.

#1603791

What is not working, exactly?

I can't reach that website, it throws a DNS_PROBE_FINISHED_NXDOMAIN

Could you elaborate on what exact issue you face and how I could eventually see the result?
It can also help if I can log in to the site to see what you have set up so far.

#1605159

I can see you have 2 PHP errors on that page:

Notice: Undefined property: Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$robots in .../wp-content/plugins/wordpress-seo/src/helpers/robots-helper.php on line 27
Warning: in_array() expects parameter 2 to be array, null given in .../wp-content/plugins/wordpress-seo/src/helpers/robots-helper.php on line 27
Notice: Undefined property: Yoast\WP\SEO\Presentations\Indexable_Post_Type_Presentation::$robots in  .../wp-content/plugins/wordpress-seo/src/helpers/robots-helper.php on line 31

These should be due to Yoast SEO.

I suggest disabling it for now, so to exclude any chance for those errors to interfere with the Toolset Setup.
Then I'd suggest reporting those errors to Yoast if you can replicate them (or if not, you might want to send them a copy of the site, if this is possible with Yoast SEO Support)

Now, that View, edited at hidden link, has Query Filter settings.
To see them, you need to activate the View for "Full Custom display mode", in the "Screen Options" of The View.
I've done that for you, now you can see the Query Filters.

Those are the ones we need to modify so we can call the page with the View and pass URL parameters

Now you need to (on hidden link) head to "Query Filter" and "Add a Filter".
Then add a or several filter(s) as I described here:
https://toolset.com/forums/topic/linking-for-a-custom-taxonomy-value-to-a-custom-search-page/#post-1600535

You will first have to choose the field you want to query by, then that you want to query by "is set by the URL parameter", where you'll have to define what you query by in the URL param and the URL param itself.

Once this is set up, you can call your page with this View, passing the URL Parameter, which will then filter the View's results.

Please let me know if this helps!

Related to the other issue, I wasn't able to spot that page, could you eventually add a new ticket, explaining where the issue happens?
This might be a hidden error or some JS problem, the way you describe it.

PS:
The above-bespoken setup of a View can also be set up in a View created directly with Blocks.
The settings bespoken would then be in the Block Inspector.
I see however you preferred the classic mode here, please let me know if you need more help with Blocks as well (it is very similar in the setup, but you will need to search for the settings in the Block Inspector)

#1605687
Annotation 2020-04-29 064057.png

For Yoast, they just put in an update. I had it disabled on live but hadn't disabled in staging.

For the view, I actually created the view directly with blocks (page is search-test) and I've attached what I set up for the query filter. I published and went to
hidden link

and it didn't filter. What am I missing?

I did go and try the other way around (built the view in the views page, added the filter, and then added this view to a page), and this one now seems to work. So thanks for letting me know about that. I'm sure I'm missing something when I set up the block one but at least this functions. I'll leave this open in case you can let me know about the block editor but the views set up did fix it.

#1605855

Well I had to wipe my staging environment so you can't get in. but if you have any ideas why block editor wouldn't work, let me know. Otherwise I'll just create the other way. thanks

#1606723

Blocks Query Filter works just as fine as Classic Views Query filters, in fact, if one works, the other works, since it's the same code base.
I tested this locally as well.

There must be an error on the site, something with the block or another plugin or eventually some typo in the query.
I've re-enabled the private reply in case you still experience this issue.

#1607119

I'll let this close. I'm going to be recreating and so maybe there was some issue, as long as I have an option, I'm fine. Thanks.