• Resolved mjepson

    (@mjepson)


    We use a featured tabber in our Headlines theme, which shows posts that you have tagged with a pre-defined tag(s) (you define it in options panel).

    We then exclude these tagged posts from the normal posts beneath the featured tabber with this query:

    <?php
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args = array( 'post__not_in' => $GLOBALS['shownposts'], 'cat' => '-'.$GLOBALS[video_id], 'paged'=> $paged ); query_posts($args);
    ?>

    This works great for the first page, but when you view previous posts (page 2), it does not exclude the posts that were excluded on page 1.

    I tried to exclude the tag directly with this code:

    <?php
    	global $wpdb;
    	$tag = $wpdb->get_var("SELECT term_ID FROM $wpdb->terms WHERE name='featured'");			
    
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    	$args = array( 'tag__not_in' => array($tag,), 'cat' => '-'.$GLOBALS[video_id], 'paged'=> $paged ); query_posts($args);
    ?>

    This does work, and it also works on page 2 and onwards.

    It seems to me that the post__not_in does not work with paged pages. Does anybody know if this is a bug, or how I can report the bug?

Viewing 1 replies (of 1 total)
  • Thread Starter mjepson

    (@mjepson)

    This is my mistake and not a WP bug… I just had an brainfart…

    The $GLOBALS[‘shownposts’] is not set on page 2 … no wonder the posts show ??

Viewing 1 replies (of 1 total)
  • The topic ‘Possible WP bug: Excluding post id’s with paged query’ is closed to new replies.