Home Forums General Issues Sort By Select Field


Sort By Select Field

  • I created a select custom field. Each post has multiple cities in the field. I’m trying to run the following query below but it’s not working.

    I set it up in the Choices box as cincinnati : Cincinnati

    $args = array(
    	'numberposts'	=> -1,
    	'post_type'		=> 'post',
    	'meta_key'		=> 'city',
    	'meta_value'	=> 'cincinnati'

    Any help would be greatly appreciated. I assume maybe it’s due to multiple values? If so what is the way around this?

  • I was able to solve this myself.

    $location = $_GET["location"];
    $args = array(
    'numberposts'   => -1,
    'post_type'     => 'post',
    'meta_query'    => array(
            'key'       => 'city',
            'value'     => ''.$location.'',
            'compare'   => 'LIKE',
  • This reply has been marked as private.
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Sort By Select Field’ is closed to new replies.