Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using a nivo silder to which I created a post to show the sliders on the home page with category 'nivo' . And I tried to exclude posts using the below code to show on the blog page. But it is redirecting me to page not found

    add_filter( 'posts_clauses', 'exclude_nivosilder_posts', 20, 1 );

    function exclude_nivosilder_posts($clauses){

        if ( is_admin() && is_edit_page() )
            return $clauses; // Don't hide when viewing tickets in admin

        if ( ! $clauses['join'] )
            $clauses['join'] = '';
        if ( ! strstr( $clauses['join'], "JOIN $wpdb->term_relationships" ) )
            $clauses['join'] .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";

        if ( ! strstr( $clauses['join'], "JOIN $wpdb->term_taxonomy" ) )
            $clauses['join'] .= " LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";

        if ( ! strstr( $clauses['join'], "JOIN $wpdb->terms" ) )
            $clauses['join'] .= " LEFT JOIN $wpdb->terms ON($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)";

        if ( $clauses['where'] )
            $clauses['where'] .= ' AND ';

        $exclude_list = "nivo";

        $clauses['where'] .= " $wpdb->terms.slug NOT IN ($exclude_list)";

        return $clauses;
    }
share|improve this question
1  
I am able to do this usig the pre_get_posts thanks Link is here –  B L Praveen Apr 29 '13 at 13:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.