WordPress.org

Ready to get started?Download WordPress

Forums

Duplicating the index display? (5 posts)

  1. novice21
    Member
    Posted 7 years ago #

    Say I have 500 posts. I want a template Page to display excerpts to all those posts (ordered by date, most recent first.) in sets of, lets say 50. So on first view you have 50 posts with navigation on the bottom taking you to the next 50, or previous 50.

    How would I go about doing that? The index page does exactly that but simply copying the index's loop wont work...my programming skills aren't top notch so I don't get whats going on...

    I know how to use the excerpt function, its the loop I'm having a problem with..

    Thanks in advance!
    (I'm sorry if someone asked this before, can you kindly include the link to that post if you've seen one?)

  2. Chris_K
    Member
    Posted 7 years ago #

    First, check out Category_Templates and Template_Hierarchy. That's most of your solution: Build an archive.php or if you want each category to act/look a bit different, go the category-x.php route.

    Now, you want 50 on each page, but you probably don't want 50 posts listed on your index (controlled at Options -> Reading). Right? That's where Custom Query String plugin becomes useful.

  3. novice21
    Member
    Posted 7 years ago #

    Thanks for the custom query string plugin, that's really gonna come in useful!

    I'm still trying to make the loop work, I've spent time reading through the articles but I cant get the following code to display anything in my template file, is there any reason why the following code would not work in a template file? It's copied straight off the loop documentation page.

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php the_excerpt(); ?>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    My header file is included as <?php get_header(); ?> at the top of the page, my Page is a template, so it doesn't need <?php define('WP_USE_THEMES', false); get_header(); ?> i tried that anyway... nothing works.

    The source code just shows a blank where the loop is...this is so frustrating..

  4. Chris_K
    Member
    Posted 7 years ago #

    Are you doing all this with a Page template? My suggestion above is very much aimed at NOT doing that. A category/archive page will work just as well (and a helluva lot easier).

    I'd suggest that you copy index.php to archive.php and remove what you don't want. Flip the_content to the_excerpt and experiment from there.

  5. novice21
    Member
    Posted 7 years ago #

    Thanks alot for your reply, I'm getting alot of head way here and I'm finally getting it. I think. Now I only need to know how to call the archive.php page. I'm having a hard time doing that.

    I was using a Page template, I didn't know that the index.php code would actually work in the archive.php page. My only problem was that my theme was using it to display archives for dates and categories...I got around that by making a category.php and date.php page so it wont fall back on the archive.php template.

    My only question now is, how do you call the archive.php file? I was getting it before when I clicked on category or date archives, but now I'm not sure how to call it with the index.php code in there.. http://www.myblog.com/archive.php or http://www.myblog.com/archive/ doesn't seem to cut it..my menu should link to the page so what would the url be?

    I really appreciate your help!!

    Edit: oh, and is there ANY way to not have the word archive in the url? the menu link is called browse..so I would love for it to reflect that. If it cant be done then bummer, I'd just get around that by including a "You're browsing the archives" or something on the page..

Topic Closed

This topic has been closed to new replies.

About this Topic