WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Static front page with mini loop (8 posts)

  1. yeleek
    Member
    Posted 6 years ago #

    http://codex.wordpress.org/Creating_a_Static_Front_Page

    Anyone done it successfully? If so examples please. And can you bring in from more than 1 category and place in different div's on the static page i.e. say 2 latest news posts in bottom left, 2 latest blog posts in bottom right with static content above.

    Thanks

  2. yeleek
    Member
    Posted 6 years ago #

    anyone - please?

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    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

  4. yeleek
    Member
    Posted 6 years ago #

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

  5. moshu
    Member
    Posted 6 years ago #

    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...)

  6. yeleek
    Member
    Posted 6 years ago #

    OK will do - ta.

  7. yeleek
    Member
    Posted 6 years ago #

    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

  8. yeleek
    Member
    Posted 6 years ago #

    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>

Topic Closed

This topic has been closed to new replies.

About this Topic