[Resolved] Filter view by shortcode based on custom field values
This thread is resolved. Here is a description of the problem and solution.
Problem:
The problem here is that the user is filtering their view by a shortcode parameter, however when a shortcode is passed into the view parameter the formatting breaks.
Solution:
In order for you to do a shortcode in shortcode type setup you will need to first ensure that you're creating a content template with our Toolset plugin. The nested shortcode setup will only work with Toolset.
This is because wordpress core dropped support for using shortcodes as attributes.
A few other plugins have added support for this but if you're creating a page through wordpress core then it won't work.
This support ticket is created 3 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hello,
1) I have a custom number field which can have multiple values - post IDs of posts of the same type. (see image attached)
2) I have a view that should filter out only posts with the ID values stored in the custom field.
3) I am trying to filter the view with Post ID filter using the "Posts with IDs set by the View shortcode attribute" option (see image attached)
4) in the page I have a shortcode for the view (see image attached)
5) I have found this ticket - https://toolset.com/forums/topic/custom-field-in-filter-with-shortcode-attribute-parameter-not-working/ but I cannot get it to work. The view is not filtered and there is some bug in the syntax - possibly some brackets, quotes,...
6) If I type some real post ID in the view shortcode, the filter works just fine...
Getting desperate, could you help, please?
Thanks very much in advance
Tom
The shortcode is to be added inside your view and it will display the value being passed into the parameter. From there you should be able to verify that the values are correct as well as the formatting.
Hello, Shane,
thanks very much for your reply. Unfortunately, the shortcode (see image attached) doesn't do anything in my case. I think the syntax error [/types]"] is the cause (see image attached). Note: I have deactivated all other plugins and the error remained.
When I change the view shortcode attribute "souvisejici" to a existing postID (4742), the shortcode works as expected (see images attached)
Perhaps the shortcode block isn't able to process the nested shortcodes.
Can you add this to a Toolset Fields and Text block and let me know if the results are the same? If they are please provide me with admin access to the site so that I can have a further look at this for you.
I'm still unable to get onto the site even with the login temporary URL. I've asked a colleague to check as well and they didn't have any luck either.
The only other option is to ensure that on your server that you're not requiring the server login for access to the page. Alternatively you can provide a copy of the entire site but this can be there as a last resort if no other access method works.
Thank you I was able to get on and found the issue.
It appears that your view with the shortcode parameter wasn't added to the content template below hidden link
It was added to a different section that isn't processed by views. Now if the shortcodes are processed directly by wordpress core then the nested shortcodes will break because wordpress had removed support for the using as shortcode as attribute.
In order for the nesting of the shortcodes to work correctly you will need to add it to the content template as I did in my example.
If you check the page you sent you will see i've added "SHANE TEST" to the section followed by the view shortcode.