Skip Navigation

[Resolved] add custom field filter to [wpv-post-body view_template="anything-loop"]

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.

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/Karachi (GMT+05:00)

This topic contains 7 replies, has 2 voices.

Last updated by hansV-6 3 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2288101

Hi,

I wonder if there is a simple method to add a custom field filter to shortcode [wpv-post-body view_template="anything-loop"]

That way I can use the same template for more WordPress pages by only modifying the custom field filter in [wpv-post-body view_template="anything-loop"] to get a different output.

I couldn't find a simple explanation for this option on your website. Can you please give me the shortcode for doing this.

Best regards, Hans

#2288325

Hi Hans,

Thank you for contacting us and I'd be happy to assist.

I'm afraid, I couldn't fully understand the requirement. Can you please share an example page where you're already using the "wpv-post-body" shortcode and the custom field filter together?

I'll be in a better position to guide you with the next steps, accordingly.

regards,
Waqar

#2288437
query.png

Hi Waqar,

Let me try to specify my request with an example.

I have created a post type X and added several custom fields. About 380 post are added to this post type X.
I have created two content templates A and B. Both content templates are using the same posts of post type X.

Content Template A has no query filter added, and showing all available posts of post type X.
Content Template B has a query filter added (see upload) , and showing only the available posts of post type X matching the (field set) query I set.

hidden link > showing all available posts without any custom field filter in the content template A
using shortcode [wpv-post-body view_template="content-template-A"]

hidden link > showing filtered posts with setting a custom field filter in the content template B
using shortcode [wpv-post-body view_template="content-template-B"]

I want to use shortcode for the query/filter used in content template B (uploaded image) in shortcode [wpv-post-body view_template="content-template-A"]. This way I only have to use content template A and I do not have to create so many Content Templates with different filter query. Is this possible?

Best regards, Hans

#2291519

Hi Waqar,

Can you help me? I replied to your return question 4 days ago.

I would be greatfull to get a reply. BR Hans

#2291893

Hi Hans,

I apologize for the delay, as I'm not sure how this ticket remained unattended for this long.

What you're planning is possible using the shortcode attributes passed through the view's shortcode.

Here is an example:

1. Suppose you have a view named 'view-to-show-books', that shows all books posts. Its shortcode would like this:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-view )


[wpv-view name="view-to-show-books"]

2. To filter the view, based on the value of the custom field with slug 'book-type', you can include a query filter, that looks for the field's value passed through the shortcode attribute 'type'.
( example screenshot: hidden link )

3. After that, you'll be able to use this same view to show different book post results, by changing the custom field value, in the shortcode attribute:

For example, to show only the books where the 'book-type' field value is 'one', the view's shortcode will be:


[wpv-view name="view-to-show-books" type="one"]

And for the books where the 'book-type' field value is 'two', the shortcode will be:


[wpv-view name="view-to-show-books" type="two"]

This way, you won't have to create separate content templates and the results from the same view can be changed, by just changing the shortcode attribute value in the view's shortcode.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#2292017

Hi Waqar,

Thank you for your help, very much appreciated.

I was able to created the view with shortcode [wpv-view name="winterregio-loop" skigebied="Bormio"]
result can be viewed on webpage hidden link

Is there an option display this result in a 3 columns grid layout? example hidden link
(this view is created with shortcode [wpv-post-body view_template="wintersport-regioloop-test"]

Best regards, Hans

New threads created by Waqar and linked to this one are listed below:

https://toolset.com/forums/topic/split-showing-view-posts-in-a-3-columns-grid-layout/

#2292735

Thanks for the update and glad that it is working now.

I've created a separate ticket for your question related to a 3 column grid layout and will reply to it shortly.
( ref: https://toolset.com/forums/topic/split-showing-view-posts-in-a-3-columns-grid-layout/ )

You're welcome to mark this ticket as resolved and start a new one for each new question or concern.

#2292817

My issue is resolved now. Thank you!