WordPress.org

Ready to get started?Download WordPress

Forums

Move Archives to Another Page (19 posts)

  1. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    You can put any sort of archives on any page, all you need is the new get_archives function and include blog.header.php at the top. The get_archives function will return any sort of archives you request, and (off the top of my head) valid arguments to it are monthly, daily, weekly, and postbypost. Weekly might have issues in the last release but that will be fixed with the next one. You can also pass a second argument to the function that limits the number of results it returns, so for example if you wanted a list of the last 8 posts to put on your sidebark you could have something like this:

      <?php get_archives('postbypost', 8); ?>


    Et cetera.

  2. pixilated
    Member
    Posted 10 years ago #

    Thanks :) I was just about to try and figure out how to do this.
    One other q ... is there any way we can get an offset in there? 10 posts before the 7 listed on the blog page for example?

  3. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    Not yet, but that's a good idea for a hack, which would be likely included in the next release if done well.

  4. southerngal
    Member
    Posted 10 years ago #

    I did try that but I keep getting an error. Don't I have to point the get_archives to the blog? I tried that as well, still an error.

  5. Matt Mullenweg
    Troublemaker
    Posted 10 years ago #

    What's the error?

  6. southerngal
    Member
    Posted 10 years ago #

    I'm getting an error saying that the path is wrong. I would paste it here, but I have fixed it by not including the archives. Not a biggie, but thanks for trying! :)

  7. southerngal
    Member
    Posted 10 years ago #

    *bump* again!

  8. Mike Little
    Member
    Posted 10 years ago #

    Ok, Southerngal this is not nice but it works!
    <form name="archiveform" action="">
    <select name="archive" onchange="window.open(document.forms.archiveform.archive[document.forms.archiveform.archive.selectedIndex].value);">
    <?php get_archives('','','option'); ?>
    </select>
    </form>
    Mike

  9. jackiefg
    Member
    Posted 10 years ago #

    Is there a way to use the code and show maybe 10 posts, but then below them there would be like a [...] to link to the rest of the posts for the month?

  10. Anonymous
    Unregistered
    Posted 10 years ago #

    Hey MikeLitt;e, that great! But how do I get that to work so it stays in the same window?
    I'm also trying to get the same thing going with the category archives. Any help would be mostly appreciated :P
    Thx!

  11. Anonymous
    Unregistered
    Posted 10 years ago #

    putting a "window.location =" instead of the "window.open" does the trick
    but I would love to know how to do the same with the category. The dropdown_cats is nice but how do I get it to work "onchange" instead of adding a submit button?

  12. MisterX
    Member
    Posted 10 years ago #

    in case someone cares, I kinda figured it out (how to get the category drop down menu to work without a "go" button), I used the same trick above from MikeLittle for the get_archives with a dropdown_cats
    It looks like that:
    [code]
    <form name="catform" action="">
    <select name="archive_cat" onchange="window.location = (document.forms.catform.archive_cat[document.forms.catform.archive_cat.selectedIndex].value);">
    <?php dropdown_cats(1, 'By Category', 'name', 'asc', 0, 0, 0); ?>
    </select>
    </form>
    [/code]
    Then I tweaked the line 1478 of the "template-functions.php" file so it looks like that:
    echo "\t<option value=\""."$siteurl".'/index.php?cat='.$category->cat_ID."\"";
    I don't know nothing about javascript and/or php I just tried to guess by comparing the files/functions... So if anyone knows a better way, feel free to educate me. I love lerning :)

  13. Beel
    Member
    Posted 10 years ago #

    So is Otaku42's suggestion going to be added? I have found it very useful and use it in lieu of the "get_recent_posts" hack - which also worked well.

  14. find
    Member
    Posted 7 years ago #

    I am trying to add <?php get_archives('postbypost', 8); ?> to a Page ( I am using semilogic's static_front_page plugin)
    How do I include "blog.header.php" to the Page so that the get_archives will work?

  15. vkaryl
    Member
    Posted 7 years ago #

    If this is a "native wp" Page, you don't need to add the wp-blog-header call.

  16. find
    Member
    Posted 7 years ago #

    It is a native page, but the code does not seem to be working.

    I put

    <?php get_archives('postbypost', '10', 'html', '', ''); ?>

    into the Page content area but the site is not pulling the info from the database. The php code is visible in the Page Source.

    see: http://www.wreckio.com/site

  17. vkaryl
    Member
    Posted 7 years ago #

    Don't you have to have one of the "run php" sorts of plugins to make this work in a Page?

  18. moshu
    Member
    Posted 7 years ago #

    Don't try to put any PHP code in the content of a post or Page. It just doesn't work.

    You either have one of those php-exec plugins that vkaryl mentioned or you create a Page template... then a Page using the template etc.

  19. find
    Member
    Posted 7 years ago #

    You were right.
    I installed Exec-PHP and now it works!

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.