How to display posts on a static page? (like search loop)

How do I display the loop inside a static page? Like the loop when I use the search (which in this theme it’s actually working) or on index.php

An example for what I’m saying can be seen here: http://www.gaganews.com.br/noticias/ I want a page like this, showing all my posts with pagination, since my home page is kinda like the homepage here: http://www.gaganews.com.br/

Read More

I tried creating a template page, this way:

<?php

 /*
Template Name: Noticias
*/

get_header(); ?>

<div id="loop"><?php if ( have_posts() ) : ?>
        <?php
            get_template_part( 'loop', 'index' );
        ?>  
<?php endif; ?>
</div>
<div id="sidebar_single"><?php get_sidebar(); ?></div>
<?php get_footer(); ?>

I’m almost 100% sure that it’s not the right way, but that’s what I tried – like it was a “classic” index.php.

Then I created a blank page with this template, but with it instead of showing the latest posts on the page, it ONLY shows the PAGE TITLE itself: “News, posted on 1 de abril de 2013 by admin | Leave a comment | Edit” etc, but with all the CSS configuration from the loop (which means it’s actually calling it, right?).

What could I do to achieve what I’m looking for?

Related posts

Leave a Reply

2 comments

  1. You could use query_posts() to set up a new loop in your page. Assuming that the posts you want are in the category ‘Noticias’, with a slug of ‘noticias’:

    query_posts( 'category=noticias' );
    if( have_posts() ) {
        get_template_part( 'loop', 'index' );
    }
    wp_reset_query(); // probably not necessary, if you don't have a pre-existing Loop