• Resolved Dan LaSota

    (@dan-lasota)


    I am attempting to construct a page template that will display whatever is on the page that user has entered, followed by all the posts in a specific category. At the bottom of the page links would be added for older and more recent posts in this category.

    I was partially successful, in that the page displays with its content on top, followed by posts, but each page has the first bunch of posts. The same posts. In my case there are currently 12. Page one has 1-5, page two has 1-5, page three has 1-5.

    What I would like is for page one to have posts 1-5, page two to have 6-10, and page three to have 11-12.

    The code for this template is located here: https://code.bulix.org/c8o3xx-69670?raw

    What am I doing wrong here?

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • If I got it right, change:

    <?php query_posts('category_name=catname'); ?>

    to

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts('category_name=catname'.'&paged=' . $paged);
    ?>

    Thread Starter Dan LaSota

    (@dan-lasota)

    That did not quite do it.
    I need it to skip ahead in the loop so that the next page contains the next batch of posts. The code above still displays the first 1-5 posts on each page.

    Look at the offset= parameter

    Thread Starter Dan LaSota

    (@dan-lasota)

    I experimented with some things and finally settled on this code fragment just before The Loop on the page:

    <?php
    if ($paged>1) {
    	$offsetAmt = ($paged-1) * 5;
    	}
    else {
    	$offsetAmt = 0;
    	};
    $queryStr = 'category_name=catName'.'&paged=' . $paged . '&offset=' . $offsetAmt;
    query_posts($queryStr);
    ?>

    Thank you very much for pointing me in the right direction.

    Hey mate,

    You should make this a plug-in as it’s something very useful! I’ve actually been searching for something like this (as i don’t really understand code) but can’t manage to find it.

    A category page that generates links to specific posts based on the category they’re in. E.g. a “south american” page, that has links single posts that are in the “South american” category. And that way you can have multiple other categories (countries), etc…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Combining Page content with category list’ is closed to new replies.