Results 1 to 4 of 4

Thread: Wordpress latest posts in sidebar (but manually).

  1. #1
    Hellas's Avatar
    Hellas is offline Very Unusual Member
    Join Date
    Dec 2008
    Location
    Bosnia
    Posts
    1,051
    Thanks
    214
    Thanked 292 Times in 205 Posts

    Wordpress latest posts in sidebar (but manually).

    Well to everyone can happen to find some extra cool theme that has not widgetized sidebar. Its easy to make your theme widget compatible but some people (like me) prefer to manually edit sidebar and insert needed option to your site.

    Here is part of code that inserts Recent posts to your sidebar.

    <div class="mycustomclass">
    <h3>Latest Guides</h3>
    <?php query_posts('showposts=15'); ?>
    <ul>
    <?php while (have_posts()) : the_post(); ?>
    <li><a href='<?php the_permalink() ?>'><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    </div>

    You will add this to your sidebar.php. And add custom styling by defining mycustomclass in your css.

  2. Thanked by:

    TopDogger (18 August, 2009)

  3. #2
    Shenron's Avatar
    Shenron is offline Administrator
    Join Date
    Dec 2008
    Location
    Portugal
    Posts
    1,900
    Blog Entries
    2
    Thanks
    561
    Thanked 548 Times in 368 Posts
    Quote Originally Posted by Hellas View Post
    Its easy to make your theme widget compatible
    And how's that? What needs to be done?

    I confess I've never tried to widgetize some of my themes. (lazy me )

  4. #3
    Hellas's Avatar
    Hellas is offline Very Unusual Member
    Join Date
    Dec 2008
    Location
    Bosnia
    Posts
    1,051
    Thanks
    214
    Thanked 292 Times in 205 Posts
    Actualy I just figured out that this code above will probably brake almost every theme.

    Here is the easier way.

    Just add to your sidebar

    <?php wp_get_archives('type=postbypost&limit=10'); ?>

    you can wrap it again in h3 tags or whatever tags you used in your theme

    <div class="whatever">
    <h3>Latest Posts</h3>
    <ul>
    <?php wp_get_archives('type=postbypost&limit=10'); ?>
    </ul>
    </div>

  5. #4
    TopDogger's Avatar
    TopDogger is offline Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    3,029
    Thanks
    345
    Thanked 902 Times in 689 Posts
    The second method works.That's what I've been using. It is easier than continually updating plugins.

    You can find all the variations here: Template Tags/wp get archives WordPress Codex
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin


Similar Threads

  1. latest finding : wordpress search replacement
    By anantshri in forum Blogging
    Replies: 2
    Last Post: 18 April, 2010, 20:52 PM
  2. More then 15 recent posts in Sidebar
    By Hellas in forum Wordpress
    Replies: 1
    Last Post: 9 July, 2009, 15:43 PM
  3. [WTH] Style Sidebar Widgets For Wordpress $25
    By Sundance in forum Contests
    Replies: 3
    Last Post: 15 June, 2009, 01:12 AM
  4. WordPress number of posts problem
    By Aquarezz in forum Wordpress
    Replies: 2
    Last Post: 30 May, 2009, 12:45 PM
  5. Wordpress blog - sidebar.php problem
    By elishevadpw in forum Wordpress
    Replies: 6
    Last Post: 25 January, 2009, 16:26 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •