• Exclude Custom taxonomy by term/category not work with pagination link

    $args['tax_query'] = array(
        array(
            'taxonomy' => 'category',
            'terms' => array('cat', 'dog'),
            'field' => 'slug',
            'operator' => 'NOT IN',
        ),
    );
    query_posts($args);

    Full code:

    <?php $args['tax_query'] = array(
        array(
            'taxonomy' => 'category',
            'terms' => array('cat', 'dog'),
            'field' => 'slug',
            'operator' => 'NOT IN',
        ),
    );
    query_posts($args); ?>
    
    		<?php if ( have_posts() ) :    ?>
    
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    			<?php link_pagination( ); ?>
    
    		<?php else : ?>

    Please help me. Tanks you for answer.

Viewing 8 replies - 1 through 8 (of 8 total)
  • So are you saying that the query doesn’t return your expected results?

    OR are you saying that it does, but they are not paginated.

    Please post with more specifics so someone can help you.

    Thread Starter Fornob

    (@jawanet)

    I mean pagination links do not work for the first page. So if you click on the next page there is only the first page continues.

    You need to pass the ‘paged’ parameter into your query args.

    Thread Starter Fornob

    (@jawanet)

    Can you give an example of my code?

    I pagination this code:

    function jseo_pagination($pages = '', $range = 3) {
        $showitems = ($range * 3)+1;
        global $paged; if(empty($paged)) $paged = 1;
        if($pages == '') {
            global $wp_query; $pages = $wp_query->max_num_pages;
            if(!$pages){ $pages = 1; }
        }
        if(1 != $pages) {
            echo '<div class="pagination"><ul>';
            if($paged > 2 && $paged > $range+1 && $showitems < $pages)
                echo '<li><a href="'.get_pagenum_link(1).'">&laquo; First</a></li>';
            if($paged > 1 && $showitems < $pages)
                echo '<li><a href="'.get_pagenum_link($paged - 1).'" class="inactive">&lsaquo; Previous</a></li>';
            for ($i=1; $i <= $pages; $i++){
                if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
                    echo ($paged == $i)? '<li class="current"><span class="currenttext">'.$i.'</span></li>':'<li><a  href="'.get_pagenum_link($i).'" class="inactive">'.$i.'</a></li>';
                }
            }
            if ($paged < $pages && $showitems < $pages)
                echo '<li><a href="'.get_pagenum_link($paged + 1).'" class="inactive">Next &rsaquo;</a></li>';
            if ($paged < $pages-1 &&  $paged+$range-1 < $pages && $showitems < $pages)
                echo '<li><a class="inactive" href="'.get_pagenum_link($pages).'">Last &raquo;</a></li>';
                echo '</ul></div>';
        }
    }
    $args['paged'] = get_query_var( 'paged' );
    $args['tax_query'] = array(
        array(
            'taxonomy' => 'category',
            'terms' => array('cat', 'dog'),
            'field' => 'slug',
            'operator' => 'NOT IN',
        ),
    );
    query_posts($args);
    Thread Starter Fornob

    (@jawanet)

    Now all of a custom type does not even appear.

    Try:

    $args['paged'] = get_query_var( 'paged' ) ?: 1;
    $args['tax_query'] = array(
        array(
            'taxonomy' => 'category',
            'terms' => array('cat', 'dog'),
            'field' => 'slug',
            'operator' => 'NOT IN',
        ),
    );
    query_posts($args);

    Thread Starter Fornob

    (@jawanet)

    Still the same, all custom post does not appear

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Exclude taxonomy by term not work with pagination link’ is closed to new replies.