WordPress.org

Support

Support » How-To and Troubleshooting » Exclusion of posts

Exclusion of posts

  • On my homepage, I have 2 modules. “Featured Content” and “Most Recent Content.” What I would like to do is exclude posts from showing Most Recent if they are showing in the Featured Content module.

    When I have one featured item, the exclusion is working fine. When there are multiple featured items, only the first item is being excluded.

    Below is my code. Any assistance would be great.

    Cheers,

    //Get Featured Posts

    $featureCheck = query_posts(“showposts=”.get_option(‘studioblue_featured_num’).”&meta_key=is_post_featured&meta_value=1″);
    $postids = array();
    foreach ($featureCheck as $catpost) {
    $postids[]=$catpost->ID;
    }
    $mypostids = implode (‘, ‘, $postids);

    //Get Most Recent and exclude featured

    $args=array(
    ‘post_type’ => array(‘post’,’video’, ‘gallery’, ‘poll’, ‘discussions’),
    ‘post_status’ => ‘publish’,
    ‘paged’ => $paged,
    ‘posts_per_page’ => 10,
    ‘category__not_in’ => array(51,77,76),
    ‘post__not_in’ => array($mypostids)

    );

Viewing 1 replies (of 1 total)
  • http://codex.wordpress.org/Forum_Welcome#Posting_Code

    because $mypostids is already an array, your ‘implode’ code does make no sense.
    also, I am not sure if a ‘foreach’ loop would work with the ‘query_posts()’ code; try to use ‘get_posts()’ instead;

    //Get Featured Posts
    
    $featureCheck = get_posts("showposts=".get_option('studioblue_featured_num')."&meta_key=is_post_featured&meta_value=1");
    $postids = array();
    foreach ($featureCheck as $catpost) {
    $postids[]=$catpost->ID;
    }
    
    //Get Most Recent and exclude featured
    
    $args=array(
    'post_type' => array('post','video', 'gallery', 'poll', 'discussions'),
    'post_status' => 'publish',
    'paged' => $paged,
    'posts_per_page' => 10,
    'category__not_in' => array(51,77,76),
    'post__not_in' => $mypostids 
    
    );
Viewing 1 replies (of 1 total)
  • The topic ‘Exclusion of posts’ is closed to new replies.
Skip to toolbar