• Resolved heidekeal

    (@heidekeal)


    Hello,

    I build a wordpress website and build the theme completely myself. The website uses 10 categories. Each post is placed in one of the categories so i have one categorie that displays all posts. The other categories are for displaying a specific category.

    Because off a lot of posts i added paging… but the problem is that each category now displays all the posts. I think because of a query problem. I need a query with paging that displays only the posts of the current category.

    i use the following code before the standard loop code:
    <?php
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query(‘showposts=5′.’&paged=’.$paged);

    ?>

    i hope someone have a suggestion!

    greetz

Viewing 3 replies - 1 through 3 (of 3 total)
  • is there a reason why you set the number of posts per page directly in the template (category.php ?) and not from the dashboard – settings – reading – blog pages show at most … ?

    try (has to be in category.php):

    $wp_query->query('showposts=5&cat='.get_query_var('cat').'&paged='.$paged);
    Thread Starter heidekeal

    (@heidekeal)

    Hello,

    Thanx for your fast solution! I tried and it works well! i use it in the archive.php and works very well now thanx again! There was no reason for the number of posts but i find it in a tutorial, thats why i use the code! I understand that put it in the settings is enough and you don’t need te showposts=5..?

    greetz!

    I understand that put it in the settings is enough and you don’t need te showposts=5..?

    exactly – as matter of fact, you won’t need the query code at all, as a category archive would automatically query the right posts (with pagination).

    review http://codex.wordpress.org/Theme_Development

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Query for current category with paging?’ is closed to new replies.