Support » Fixing WordPress » How to: The Loop like wordpress.org

  • Please look at: my site here. I have set up a page on my site, ‘contact’ for the time being, with a template, in which I have the following ‘Loop’:

    <?php
    $how_many=5; //How many posts do you want to show
    require_once('wp-config.php'); // Change this for your path to wp-config.php file ?>
    <ol id="whats-new">
    <?
    $news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code> FROM $wpdb->posts
    WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
    foreach($news as $np){
    printf ("<li><a href=\"%s\">%s</a></li>", get_permalink($np->ID),$np->post_title);
    } ?>
    </ol>

    I got this from the supportsection somewhere here on wordpress.org. The result I am looking for is, actually, that of the wordpress.org ‘blog’, simply a page that lists all posts, no matter what category, with in the sidebar ‘categories’ and ‘archives per month’, and an ‘older posts’ link at the bottom. what is the code I need to use? Am I on the right track? Who knows how to add to this? what to change? Where to start? I am a beginner in the worst way. If anyone would like to look at my code, or theme, just ask. Any help will be thankfully received!

  • The topic ‘How to: The Loop like wordpress.org’ is closed to new replies.