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.

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.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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(); ?>
share|improve this answer

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.

share|improve this answer
    
Hmm, this seems like you are query-ing a specific taxonomy. I don't want to do that in this case. I just want to find a better way to write pagination and posts_per_page on a boring old normal "if have posts" wordpress loop. ie: write in pagination without using a custom query. I guess I was't clear enough. –  Nadine Mar 5 '12 at 23:01

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.