Home Forums Backend Issues (wp-admin) True/False to exclude list items


True/False to exclude list items

  • I am using the below to successfully output a list.
    I have added a new field (true/false) to check if a list item returns true or false.
    How can i modify the code below to check if something returns ‘false’ and prevent it from showing in my list if it does? The true/false field name is ‘artist_link_homepage’.

       $posts = get_posts(array(
        'numberposts' => -1,
        'post_type' => 'artist',
        'meta_key' => 'artist_location',
        'meta_value' => 'new york',
        'orderby' => 'title',
        'order'	=> 'ASC'
       	echo '<ul class="artists">';
       	foreach($posts as $post)
       		echo '<li><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</a></li>';
       	echo '</ul>';
  • The the section on multiple custom field hadnling You need to adjust your meta query to include the new field.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.