Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Reply To: Filtering Views by Custom Field?

$
0
0

Hmm,

Well, egg on my face. I just wasn't being creative.
For anyone else who wants to know how to do this, here's what I did:

Make a template for your landing page (I have three: Things to Do, Places to Eat, Places to Stay).
Next, make a custom field that is a required (optional) option on your custom post types (again, I have three: Things to Do, Places to Eat, Places to Stay)

Now, in the template assign the raw value of the field to a variable, then insert that variable into the views shortcode:

<?php 
$ccCity = do_shortcode('[types field="city" output="raw"][/types]');
echo do_shortcode('[wpv-view name="Landing Page - Things To Do" city="'.$ccCity.'"]');
?>

Now the user can select, on the page edit screen, what city they want to filter the posts by and they can choose which custom post type to display based on the template they choose.

Problem solved… unless someone has a more elegant way of going about this?

Thanks all!


Viewing all articles
Browse latest Browse all 20145

Trending Articles