Support

Account

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

Helping

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’.

    <?php
       $posts = get_posts(array(
        'numberposts' => -1,
        'post_type' => 'artist',
        'meta_key' => 'artist_location',
        'meta_value' => 'new york',
        'orderby' => 'title',
        'order'	=> 'ASC'
       ));
       if($posts)
       {
       	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 https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters. You need to adjust your meta query to include the new field.

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

The topic ‘True/False to exclude list items’ is closed to new replies.