WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Static front page with mini loop

[Resolved] Static front page with mini loop

Viewing 7 replies - 1 through 7 (of 7 total)
  • anyone – please?

    Moderator Samuel Wood (Otto)

    @otto42

    WordPress.org Tech Dude

    What’s the problem? You have the link to the documentation. Read that and it tells you how to do it.

    Or read these if you need more help:
    http://codex.wordpress.org/Pages#Page_Templates
    http://codex.wordpress.org/Pages#Creating_your_own_Page_Templates
    http://codex.wordpress.org/Pages#Examples_of_Pages_and_Templates

    Asked if people have done it successfully, for examples – and asked if you can have two different catagories coming on the same static page.

    For different categories see the Multiple Loops at The_Loop page.

    Also, be aware that in WP 2.2 you can set your frontpage from the admin panel. (which means the Codex might be a bit outdated…)

    OK will do – ta.

    Struggling with this… Been through loads of forum articles. Given the standard mini loop (below) what do i need to add to get it to look in a specific category?

    <?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_status</code>= \"publish\" ORDER BY 'ID' DESC LIMIT ".$how_many);
    foreach($news as $np){
    printf ("
    <li><a>%s</a></li>
    ", $np->ID,$np->post_title);
    }?>
    </ol>

    Thanks

    Ironically – found a different example and it works…

    <div id="left">
    <h2>Latest News</h2>
    <?php $posts = get_posts( "category=3&numberposts=5" ); ?>
    <?php if( $posts ) : ?>
    <ul>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <li>
    
    <a href=<?php the_permalink() ?>>
    <?php the_title(); ?>
    </a>
    </li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    </div>
    
    <div id="right">
    <h2>Latest blog</h2>
    <?php $posts = get_posts( "category=4&numberposts=5" ); ?>
    <?php if( $posts ) : ?>
    <ul>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <li>
    
    <a href=<?php the_permalink() ?>>
    <?php the_title(); ?>
    </a>
    </li>
    <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    
    </div>
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] Static front page with mini loop’ is closed to new replies.
Skip to toolbar