tag.php pagination and query_posts()

Having some issues on the tag.php page.

Right now it just give me a “nothing to show” If I have no query it shows posts, but I want to change the number of posts per page.

Read More

Changing the reading settings in the admin is not an option in this case, so I’m looking for template tag ideas only.

Any suggestions on ways to re-write this properly?

Thanks, sorry if this question is really boring.

<?php 
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $tags = array(
    'posts_per_page' => 10,
    'paged' =>$paged
    );?>


    <?php query_posts($tags); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

Just as an edit: I am looking for some syntax help to write some code for posts_per_page and pagination that is structured for just a plain wordpress loop.

Thanks, sorry if it was a bit confusing.

Related posts

Leave a Reply

2 comments

  1. After some other attempts I Found the syntax solution I was looking for. Just sharing.

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
          query_posts($query_string .'&posts_per_page=10&paged=' . $paged);
    
          if (have_posts()) : while (have_posts()) : the_post(); ?>
    
  2. Hope this help

    $story_type = $_GET['type'];
    if ( get_query_var('paged') ) {
        $paged = get_query_var('paged');
    } elseif ( get_query_var('page') ) {
        $paged = get_query_var('page');
    } else {
        $paged = 1;
    }
    $alt_query = array (
        'tax_query' => array(
            array(
                'taxonomy' => 'lot-term',
                'terms' => $story_type,
                'field' => 'slug',
            ),
        ),
        'post-type' => 'story',
        'paged' => $paged
    );
    query_posts($alt_query);
    

    Just copy pasted from my recent work. Just change the ‘tax_query’ with your own tag query & the ‘post_type’ value.