• Hello everyone,

    I use <?php query_posts(‘post_type=seodating_profile’);?> to query some custom posts (this works perfectly).

    Now i want my blog ONLY to show custom posts with a certain value in a custom field.

    Like: show the posts where the (value of the custom field) city is New York.

    What should i add to my code?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You have to add a ‘meta_query’ parameter.

    Example:

    <?php
    $args = array(
    		'meta_query' => array(
    			array(
    				'key'     => 'city',
    				'value'   => 'New York',
    				'compare' => '!=' // Make sure the field has a value (i.e. 'city' != null)
    			)
    		 ), // End of meta_query
    		 'post_type'  => seodating_profile,
                  );
    $query_posts = new WP_Query( $args );
    ?>
    Thread Starter joeyheuts

    (@joeyheuts)

    Thank you for taking the time to react to my question.

    but the above code doesnt show the profiles that i want it to show, it shows me a page that i created earlier. You can check my site here: https://sexze.nl/stadnaam/

    the posts should apear as they are in https://sexze.nl/ but i only want to let some appear (with a custom field value matching my criteria).

    Hope you understand my poorly written english text.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘only show posts with custom field value’ is closed to new replies.