Support » Plugin: Featured Item Metabox » not working with multiple post types

  • Resolved horria

    (@horria)


    Hello,

    Very nice plugin! However I have a problem with the query, when including custom post types. My query is:

    $args = array(
    		'post_type' => array ('post','page','newsletter'),
    	   	'meta_query' => array(
    			array(
    	       	'key'        => '_featured',
        	   	'value'      => 'yes',
    			)
        )	);
    
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query($args);

    But it displays only posts and pages, not the custom post type “newsletter”.
    However, if I delete ‘post’,’page’,and leave only ‘newsletter’, it displays the newsletters.

    But I can’t get it to show all 3 at the same time.

    Am I missing something?
    Thanks

    http://wordpress.org/plugins/featured-item-metabox/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    Sorry for the delay. Apparently, I was not yet subscribed to this forum.

    I tested with posts, pages and products because that’s what I had available and it works just fine.

    $args = array(
    	'post_type' => array ('post','page','product'),
       	'meta_query' => array(
    			array(
    	       	'key'        => '_featured',
        	   	'value'      => 'yes',
    			)
        )	);
    
    // The Query
    $the_query = new WP_Query( $args );
    
    // The Loop
    if ( $the_query->have_posts() ) {
            echo '<ul>';
    	while ( $the_query->have_posts() ) {
    		$the_query->the_post();
    		echo '<li>' . get_the_title() . '</li>';
    	}
            echo '</ul>';
    } else {
    	// no posts found
    }
    /* Restore original Post Data */
    wp_reset_postdata();

    Don’t forget that by default the query will not show ALL of the featured posts, but will only get the first 10, or however many you have set in the “posts per page” setting. Therefore if all you have 10 or more featured posts and pages, more recent than your featured newsletters you’ll never see any newsletters show up in your above query.

    Thread Starter horria

    (@horria)

    Thanks for your reply.
    Unfortunately I’ve tried with your code and the problem is the same. It displays post and pages OR newsletters, but not all 3 at the same time.
    I’ve checked posts per page and also many other settings, also reduced the query to a minimum but problem persists

    Plugin Author HelgaTheViking

    (@helgatheviking)

    I’m sorry you can’t get it to work. But since this is an issue with your query maybe you should try re-posting in the regular forums or at WordPress Answers.

    Something must be interfering with the query, so I would suggest disabling other plugins, switching to the default theme, verifying that you have a very recent featured “newsletter”, and double-checking how the newsletter post type was registered (public, queryable, etc).

    Thread Starter horria

    (@horria)

    Ok I will try, thanks for your reply.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘not working with multiple post types’ is closed to new replies.