Skip Navigation

[Resolved] View by Url Parameter not Working

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am trying to set up a view by url parameter. I have created the custom user field "test" that holds the ids of the posts but I do not know how to create the link that will output the ids in url.

Initially I used this code in the view template:

<a href="?test=[types usermeta='test' user_current='true' separator=',' output='raw'][/types]">show posts with ids same with the values from the custom field test</a>

The posts appear seperated by a comma in the url like:
domain.com/view-post-query/?test=1830,697,2167
and the view shows only the first post from the list

I visited this url:
http://ecommerce-wordpress.discover-wp.com/product-comparison/?post_ids%5B%5D=1170&post_ids%5B%5D=892&post_ids%5B%5D=795

Solution:

Please try this:

<a href="?test=[types usermeta='test' format='FIELD_NAME[]=FIELD_VALUE' user_current='true' separator='&'][/types]">show posts with ids same with the values from the custom field test</a>

And test again.

Relevant Documentation:

This support ticket is created 6 years, 11 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.

Our next available supporter will start replying to tickets in about 1.24 hours from now. Thank you for your understanding.

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)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#599051

I am trying to set up a view by url parameter. I have created the field "test" that holds the ids of the posts but I do not know how to create the link that will output the ids in url.

1) Initially I used this code in the view template:

<a href="?test=[types usermeta='test' user_current='true' separator=',' output='raw'][/types]">show posts with ids same with the values from the custom field test</a>

The posts appear seperated by a comma in the url like:
domain.com/view-post-query/?test=1830,697,2167
and the view shows only the first post from the list

I visited this url:
hidden link

and I realized that the ids have to be seperated by &test[]= so I manually changed the url to:
domain.com/view-post-query/?test[]=1830&test[]=697&test[]=2167

Bingo! The view now shows the three posts with the ids 1830,697,2167

The new issue now is that although I changed the seperator inside the shortcode to &test[]= inside the url the ids appear without seperator so the view is not working

My link now is

<a href="?test[]=[types usermeta='test' user_current='true' separator='&test[]=' output='raw'][/types]">show posts with ids same with the values from the custom field test</a>

and the url becomes:
domain.com/view-post-query-paginated/?test[]=18306972167

What would be the proper way to make it work?

#599178

Dear ioannis,

Please try this:

<a href="?test=[types usermeta='test' format='FIELD_NAME[]=FIELD_VALUE' user_current='true' separator='&'][/types]">show posts with ids same with the values from the custom field test</a>

And test again.

#600061

Excellent, Luo thank you so much!!!

#600066

You are welcome