WordPress.org

Ready to get started?Download WordPress

Forums

Always showing same posts in Next/Previous page links (19 posts)

  1. peteraltenberg
    Member
    Posted 5 years ago #

    Please, please, please can someone at least tell me if this is stupid question, or if I'm doing something wrong, or if it's not possible to do, orif I'm just wasting my time and should just keep all my posts on one humongo page. I've searched and followed a bunch of threads but can't get it working.

    I got the next/previous page links to show up after finding some tips on this forum. And, I've seen this problem in other threads where you go to a next or previous page but none of the solutions I see work and I still see the same posts on all pages.

    I'm using the $paged thing in my query_posts() as someone suggested like this:

    <?php
    if (is_page()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("category_name=hpay-podcast&paged=$paged");} ?>

    <?php $posts = get_posts('category_name=hpay-podcast&showposts=6');
    foreach ($posts as $post) : start_wp(); ?>

    and then at the bottom of my template page I have:

    <div class="alignleft"><?php posts_nav_link('','','« PREVIOUS PAGE') ?></div>
    <div class="alignright"><?php posts_nav_link('','NEXT PAGE »','') ?></div>

    Is there something I'm doing wrong here?

  2. blogsdna
    Member
    Posted 5 years ago #

    Are you talking about showing previous page and next page on pages or posts???? Do not confuse with pages and posts

    To show previous and next posts on single post page you have to use http://codex.wordpress.org/Template_Tags/previous_post_link and http://codex.wordpress.org/Template_Tags/next_post_link

  3. moshu
    Member
    Posted 5 years ago #

    I'm using the $paged thing in my query_posts()

    Let's get back to the basics. Why do you need a query_posts on a normal index file? - Answer: you don't.

    Does the next/prev work if you switch to the default theme?

  4. peteraltenberg
    Member
    Posted 5 years ago #

    First, I'm talking about posts, a "page full" of posts, not going to different WP Pages, and I'm not talking about a single post page either (I already have the single post page working with next next_post_link and previous_post_link). I have a Page that is my blog, not the main index page, and I would like to have the latest 6 or so posts when you go to that page. Then I would like to be able to go to a previous page full of older posts, and then you could go forward or backward with next/prev to page fulls of older or newer posts.

    As for the query_posts(), the only reason I put that code there is because it was supposed to make the next/previous page links work. Maybe that redundancy is causing problems? Now I tried taking out the whole query_posts() thing and the next/prev links are still showing up but the same thing happens. That is, if I click on Previous it shows the same posts as the first page I was on. I did try switch to the default theme but the problem there is that I had a custom Page for these posts which doesn't exists in the default theme.

    Could this have something to do with permalinks? I also just noticed this in the info about posts_nav_link: "...featured only on the non-single/non-permalink web pages."

    Thanks very much for the help.

  5. moshu
    Member
    Posted 5 years ago #

    Your problem is that you write a lot but give little info.
    You should have started from the beginning by giving the proper information:
    1. you have a static page set as your frontpage and another one as your "posts page" (details in admin > Settings > Reading)
    2. you have a custom Page template for that Page
    3. you are trying to make the next/prev to work on a Page

    In general:
    a) next/prev do NOT work on Pages
    b) custom queries tend to break the next/prev navigation

  6. peteraltenberg
    Member
    Posted 5 years ago #

    OK, thanks very much for the info. Sorry about not being concise but since I'm sort of new at this I'm not sure what information is relevant so I tend to ramble with all the info I think might help. I do not have a static page as my frontpage but I guess that doesn't matter since I'm trying to get next/prev working for a Page template.

    You verified what I was starting to be suspicious of, that next/prev do not work on Pages. So now I can stop banging my head against the wall trying to get this working and figure out another solution. So does this mean if I'm using Pages for my posts that I'm stuck with having all my posts listed on one page? Or is there a plug-in or some other method?

  7. moshu
    Member
    Posted 5 years ago #

    I do not have a static page as my frontpage but I guess that doesn't matter since I'm trying to get next/prev working for a Page template.

    If you don't. then why the heck are you using a Page? Why not modifying the index.php - if necessary?
    I just don't get what you are trying to do. Sometimes, new users tend to over-complicate even the simplest things...

  8. peteraltenberg
    Member
    Posted 5 years ago #

    It's quite possible that I'm over-complicating things. I have an index page that is modified from a theme index page I used. This index page only has the latest 2 posts on it with excerpt text and no comments. Then I have a Page, also modified from the theme, that has our "blog" on it, which is basically the same as the index page but with all of the posts listed and with more detailed info. You can check out how it works now at http://www.howpositiveareyou.com/.

    Am I using Pages in the wrong way? Maybe I can have a second index page layout?

    Thanks.

  9. moshu
    Member
    Posted 5 years ago #

    Am I using Pages in the wrong way?

    I'd say: the complicated way.
    The simple way:
    Convert your index to (save as) a Page template. Redo the index to its initial state (=before your mods)
    Make sure you have a regular page.php template, too.
    (see Template_Hierarchy)

    Then create 2 Pages in Write > Page.
    One (e.g. Home) using the special Page template (formerly known as index)
    Another one (e.g. blog) - using the plain Page template.

    Now go to Settings > Reading and select to have a static page as front = Home; and "Blog" as your "posts page".

    It should work and the next/prev also should work on it automatically.

  10. peteraltenberg
    Member
    Posted 5 years ago #

    Thanks once again for the help. Now I think I'm starting to understand a bit how it should be set up. It all makes sense and I tried the simple way you described but I'm not getting good results. The home page now looks like it should except that the <read more...> doesn't happen anymore. It shows all of the content. Does that only work on the blog page?

    Then, the blog page is coming up with the same layout as the home page even though I assigned it to use the plain Page template I made.

    Also, I don't understand is redoing the index to it's initial state. Do you mean pretty much back to the state it was in from the theme? From the template hierarchy chart it looks like the index page usually won't even come into play.

  11. moshu
    Member
    Posted 5 years ago #

    The home page now looks like it should except that the <read more...> doesn't happen anymore. It shows all of the content.

    Don't get lost in details... there is a workaround for that. Out of the box it should NOT work, because there is no need (in theory) for "more" on a Page. Is the rest OK?

    index to it's initial state. Do you mean pretty much back to the state it was in from the theme?

    Yes! Trust me, it comes into play! as you already experienced it...

    That's why I said: go back to the beginning of your messing-around-process and start it the right way.

  12. peteraltenberg
    Member
    Posted 5 years ago #

    The home page is working fine, except for the 'read more'. The blog page doesn't work, it still is somehow using the format of the home page and not the plain Page template.

    I'm not sure exactly what the initial state of my index page should be. Does seem it should be the same as the index page of the theme I used because I changed a lot of elements. Do you mean just make it have a standard loop for posts and the header, sort of like the Page template?

  13. moshu
    Member
    Posted 5 years ago #

    Yes, standard Loop in the index, nothing else, without your modifications. Also, no div (layout) modifications.

  14. peteraltenberg
    Member
    Posted 5 years ago #

    Sorry, but I'm getting confused. Seems like no matter what I do the blog page doesn't use the Page template that I specified it to use.

    I don't understand what the index page should be. Without which modifications? I've tried putting it completely back to the original index from the theme I used and I've tried just putting the basic header and a standard Loop that puts the title and posts and still get the same results. There are some divs to make the layout work with the columns but nothing else. Are those div modifications?

  15. moshu
    Member
    Posted 5 years ago #

    OK, you will have to explain to me what is not working on it:
    http://www.howpositiveareyou.com/blog/
    this page looks exactly like the rest of the site... I thought that's the idea for consistency!

    And the main/front page: http://www.howpositiveareyou.com/ has a custom look

  16. peteraltenberg
    Member
    Posted 5 years ago #

    OK, sorry, that's because I changed it back to the old way of having the index page be the main page. Now I've just switched it to using a the home page as a static page and the blog as the posts page. I'll leave it like that for a bit. You can see that the home page and blog page have the same look with only two posts, sidebars, etc. The blog page should not have the left "your hosts" box or the right "latest episodes" box either. It should just be the posts.

  17. moshu
    Member
    Posted 5 years ago #

    If they have the same look ... they must be using the same template file.

    take my name here At transycam dot net and send over a zipped package of that theme. I can't believe it doesn't work if you did it as I described it :)

  18. peteraltenberg
    Member
    Posted 5 years ago #

    Tried to send it to moshu at transycam dot net but bounced. Is that not the name?

  19. moshu
    Member
    Posted 5 years ago #

    Oops, not M but N (typo, sorry): transycaN (as is CANada)

Topic Closed

This topic has been closed to new replies.

About this Topic