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

    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