WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to break posts into pages with 25 posts per page? (32 posts)

  1. Tara
    Member
    Posted 4 years ago #

    Hi,

    I use the following function to list all archive posts.

    /archive">

    How can I break posts into pages with say 25 posts per page?

    Your help will greatly be appreciated. Thanks

  2. vtxyzzy
    Member
    Posted 4 years ago #

    I am not familiar with that function. Does the setting under Admin->Settings->Reading->'Blog pages show at most ___ posts' work?

  3. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy,

    This is different. For some reason I was unable to paste the whole function yesterday. I am going to try again.

    <blockquote"<?php bloginfo('url') ?>/archive">Full Archive
    it displays a complete list of all posts by title.

    Now they all show on one page. I just want to break them down between 10 to 25 on a page.

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    Use the "code" button (next to b-quote) or put code inside backticks (as indicated at the bottom of the reply box), when posting code in the forum... ;)

  5. Tara
    Member
    Posted 4 years ago #

    Thanks t31os, here it is:

    `<li<?php
    if (is_page('Archive'))
    {
    echo " id=\"current\"";
    }?>>
    /archive"> Archive Titles

    Edit: still did not show up all of it. But the missing piece is in the previous post.

  6. Mark / t31os
    Moderator
    Posted 4 years ago #

    Forgive me, but it's not clear what the code is you're using, nor what it is you want to do with it.

  7. Tara
    Member
    Posted 4 years ago #

    Thanks t31os,

    This just a link in the menu, if clicked it shows a list of all archive post (by title). Then the user can click on the title to see the full text of that title. That's all.

    Please forgive my ignorance, I am going to try post the function again:

    <li><a href="<?php bloginfo('url') ?>/archive">Full Archive</a></li>

  8. Mark / t31os
    Moderator
    Posted 4 years ago #

    Ok, but the link to the arhive doesn't have anything to do with what happens on the archive page, so i'm still a little puzzled how that relates to your original question.

    Can you clarify please.

  9. Tara
    Member
    Posted 4 years ago #

    Thanks t310os for your patient with this non-geek/no-coder/non-dev.

    At present the shows all post on poge (this makes it qite a lenthy list).

    I am just trying to break the list down into pages with 25 items (that is, titles of posts) per page.

  10. vtxyzzy
    Member
    Posted 4 years ago #

    If you posts are on an 'Archive' page, you might be able to use the Different Posts Per Page plugin.

  11. Tara
    Member
    Posted 4 years ago #

    thanks vtxyzz,

    I try to stay away from plugins.

    I thought may be I can do somthing simple as:
    bloginfo('url&limit_per_page=20'

    so if there is simple function something that, please tell me. Thanks

  12. vtxyzzy
    Member
    Posted 4 years ago #

    You are missing a good thing if you don't use plugins. The answer to a lot of questions is to use a good plugin.

    The bloginfo('url') is just returning the URL to the blog so it can be used to find full URL to the archive template. It doesn't have any parameters, and doesn't affect the way the archive is displayed.

  13. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy

    I will look into plugins.

    Meanwhile, is there a something this sort of code:

    bloginfo('url&limit_per_page=20')

    Thanks

  14. Mark / t31os
    Moderator
    Posted 4 years ago #

    Open up your archive.php for your theme, find this line..

    if(have_posts()) :

    Look to see if there's a query_posts() call before that, if not go ahead and add the following before that line...

    // Globalise the wp_query variable to get the already set vars
    if(!wp_query) global $wp_query;
    // Merge a new parameter with the existing ones into the query
    query_posts( array_merge( array( 'posts_per_page' => 25 ) , $wp_query->query ) );

    Does that help?

  15. Tara
    Member
    Posted 4 years ago #

    Thanks t31os,

    That did not break the list in 25 per page.

    I guess there has to be a simple solution somthing like this:

    <?php bloginfo('url&per_page=25') ?>

  16. vtxyzzy
    Member
    Posted 4 years ago #

    I am afraid that you are in for disappointment if you insist on looking for that. bloginfo does not do that.

    t31os_ is on the right track. I don't understand why that didn't work, unless the posts are being displayed by something other than archive.php.

  17. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy,

    I don't understand why that didn't work, unless the posts are being displayed by something other than archive.php.

    No.

    In fact, I am not using any plugins or woidgets. I use default theme. Pretty simple board.

    I want to thank both of you for patient and help.

    happy new Year!

  18. vtxyzzy
    Member
    Posted 4 years ago #

    OK, you are using the default theme. Did you actually try setting posts per page as I suggested in the first reply? That works for me in the default theme for archive pages.

    Have you edited some of the code in the theme? Where in the code is the function you posted?

  19. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy,

    OK, you are using the default theme. Did you actually try setting posts per page as I suggested in the first reply? That works for me in the default theme for archive pages.

    Yes, that works fine.

    Have you edited some of the code in the theme? Where in the code is the function you posted?

    The above code worked fine to control the sidbar archive (post per page=25) when placed in the archive.php as suggested by t31os_

    Which I have already set through the admin (setting posts per page).

    However, what I am trying to accomplish is different than the archive elemment in the sidebar.

    I have created a page, which is linked in the horizontal menu bar below the header. I call it "Full Archive". When a user clicks on it, that users sees a complete list of all posts alphabetically listed by titile and bulletizd on one page. What I intend to do is, instead of having that list including all titles on just one page, break it down to, say 25 titles per page.

    Now this totally different than the archive element in the sidebar or the admin setting of posts per page.

  20. vtxyzzy
    Member
    Posted 4 years ago #

    Now we may be getting somewhere. I assume you wrote a template php file for your Full Archive page.

    Can you post a section of the code from that template? Say five or so lines before and after the loop, the 'while (have_posts())' part?

  21. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy, here is that entire template:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    /*
    Template Name: gurarchive
    */
    ?>
    
    <?php get_header(); ?>
    
    <div id="content" class="widecolumn">
    
    <h2></h2>
    <ul>
    <?php wp_get_archives('type=alpha');?>
    </ul>
    
    </div>
    
    <?php get_footer(); ?>
  22. vtxyzzy
    Member
    Posted 4 years ago #

    I have created a file that I think will work for you. You can get it from WordPress pastebin.

    If this works, please mark this topic 'Resolved'.

  23. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy,

    Appreciate your help.

  24. Tara
    Member
    Posted 4 years ago #

    Hi vtxyzzy,

    thanks for helping the other day.

    Itried your code, and found couple of problems with it.

    1. pagination, page 1 comes out ok, but when clicked on the subsequent pages (page 2, 3, etc.), I end up at my blog's front page!

    2. w3validator indicates bunch of errors and warnings.

    It's possible when #1 is fixed, #2 may go away.

    I tried to fix these both issues but no luck.

    Again thanks for your help. TaraP

  25. vtxyzzy
    Member
    Posted 4 years ago #

    I will look into this right away. Sorry for the trouble.

  26. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy,
    I Appreciate your help greatly.

  27. vtxyzzy
    Member
    Posted 4 years ago #

    Are you using pretty permalinks? I think that the program may fail because of that. I am using that same code in a number of places and it works, but none of them have pretty permalinks. I will modify to fix that and send a new copy in a day or two.

  28. Tara
    Member
    Posted 4 years ago #

    yes vtxyzzy, I am using pretty permalinks. Thanks for your time and patient.

  29. vtxyzzy
    Member
    Posted 4 years ago #

    OK - I think I have it fixed. Get the new one from http://wordpress.pastebin.ca/1747743.

    Be sure to change the $limit back to 25; I set it to 4 for testing so I would get lots of pages.

  30. Tara
    Member
    Posted 4 years ago #

    Thanks vtxyzzy,

    It works!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.