Support

Account

Home Forums Front-end Issues Don't show custom post type if select field equals 'no'

Unread

Don't show custom post type if select field equals 'no'

  • I’ve got a custom post type called ‘cars’ and it pulls through the data fine. I’ve got them arranged by price of each car.

    What I want to do next is “if” the custom field ‘sold’ equals ‘no’, meaning it hasn’t been sold – show these cars, where as if it has been sold to remove it from the list.

    The ‘sold’ field is a Radio Button.

    This is what I have so far and the sold cars still show;

    $args = array(
        'post_type'     => 'cars',
        'posts_per_page' => 999,
        'orderby' => 'meta_value_num',
        'order' => 'DESC',
        'meta_query'    => array(
            'relation'      => 'OR',
            array(
                'key'       => 'price',
                'type'     => 'NUMERIC'
            ),
            array(
                'key'       => 'sold',
                'value'     => 'No',
                'compare'   => 'LIKE'
            )
        )
    );

    Can anyone help or advise please?

Viewing 1 post (of 1 total)

The topic ‘Don't show custom post type if select field equals 'no'’ is closed to new replies.