WordPress.org

Ready to get started?Download WordPress

Forums

Post nav links does not display in page of posts (3 posts)

  1. jobzilla
    Member
    Posted 5 years ago #

    Hi,
    I made a blog that has my posts on the home page. I also have other pages that display only certain categories. I used the the template page of posts found in the documentation to do so. The problem is, the post nav links do not work on the other pages (the ones using the page template, page of posts).

    <?php
    /*
    Template Name: PageOfPosts
    */

    get_header(); ?>

    <div id="content">
    <div id="content-main">

    <?php
    if (is_page('58') ) {
    $cat = array(115);
    } elseif ( is_page('439') ) {
    $cat = array(170);
    } elseif ( is_page('28') ) {
    $cat = array(17);
    } elseif ( is_page('1108') ) {
    $cat = array(460);
    } else {
    $cat = '';
    }

    $showposts = 0; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
    'category__in' => $cat,
    'showposts' => $showposts,
    'caller_get_posts' => $do_not_show_stickies,
    );
    $my_query = new WP_Query($args);

    ?>

    <?php if( $my_query->have_posts() ) : ?>

    <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <?php
    //necessary to show the tags
    global $wp_query;
    $wp_query->in_the_loop = true;
    ?>

    my index has this:

    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-115,-170,-179,-460&paged=$paged");
    }
    ?>
    <?php get_header();?>
    <div id="content">
    <div id="content-main">

    and the pagination works perfectly. all help is appreciated. i'm really new to php. Thank you so much

  2. Rindy Portfolio
    Member
    Posted 4 years ago #

    Having the same problem. Any help?

  3. alchymyth
    Forum Moderator
    Posted 4 years ago #

    exactly the same?

    well, part of the answer is in the post above:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    try and add that to the 'page-of-posts' at the corresponding place:

    $showposts = 0; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args=array(
    'category__in' => $cat,
    'showposts' => $showposts,
    'paged' => $paged,
    'caller_get_posts' => $do_not_show_stickies,
    );
    $my_query = new WP_Query($args);

    should work ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic