• It don’t know if it’s a bug or just my stupidness…

    I have the following problem: If a special category or a subcategory is rendered with the archive template, i want it to show only one post per page and add a special paging navigation. This all works great in the main category. But if I want to browse a subcategory, it seems to me, like the post_per_page, which i attach to the query, gets overridden and browsing to a higher page results a 404. The generated paging link works, if if set posts per page in the WordPress setting to 1. Here is my code:

    // set up posts_per_page to show only one fotoblog entry per page
    
    		query_posts($query_string.'&posts_per_page=1');
    
    		//get current page number
    		intval(get_query_var('paged')) == 0 ? $curpage=1 : $curpage = intval(get_query_var('paged'));
    
    		//get max page number
    		$total_pages = $wp_query->max_num_pages;
    
    		//setup previouspage and nextpage: Some Paging Calculation
    		$prevpage = 0;
    		$nextpage = 0;
    
    		if( ($curpage > 1) && ($curpage < $total_pages) ) {
    			$prevpage = $curpage - 1;
    			$nextpage = $curpage + 1;
    		} elseif ( $total_pages == 1 ) {
    			$prevpage = 1;
    			$nextpage = 1;
    		} elseif ( $curpage == 1 ) {
    			$prevpage = $total_pages;
    			$nextpage = $curpage + 1;
    		} elseif ( $curpage == $total_pages ) {
    			$prevpage = $curpage - 1;
    			$nextpage = 1;
    		}
    
    		while (have_posts()) : the_post();

    I also tried to set the category hardcoded in the query, but i achieved the same results for subcategories.

    Some ideas?

    Sorry for my bad english. Greetings,
    voetzi

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

    (@voetzi)

    Update: The resulting page is not the 404 but the Search: Nothing found page… Sorry

Viewing 1 replies (of 1 total)

The topic ‘Subcategories and post_per_page query_posts not working’ is closed to new replies.