Home › Forums › Front-end Issues › how can get post filter by select item › Reply To: how can get post filter by select item
Hi @pagol,
One way to achieve this would be: First, have two pages, one to display the Choices/tabs and the other one to display the posts for a particular chioice/tab.
On the template for the page that displays the posts, add the following code:
$value = $_GET['value']; // get value of selected choice.
$args = array(
...
'meta_key' => '<select_field_name>',
'meta_value' => $value
);
$the_query = new WP_Query( $args );
... // display posts
Where $value will be the value of the selected choice/tab passed through a query string e.g. The CK tab could open this link http://your-domain.com/page-that-displays-posts/?value=CK
For more info on this, have a look at the following resources:
Filter posts by custom fields,
Creating a WP archive with custom field filter
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.