0

I have tried to create an index page of all my blogs on a menu link: Blog

I created a new page: Blog (id:267)

I copied archive.php to page-267.php

Yet, when I view this page, it only shows one result - the Blog Page - why is it not listing all blogs in the archive like the archive page should?

What am I missing?

0

A template with a standard loop just outputs the contents of the main query, which is based on the requested URL. WordPress loads specific templates based on the results of the main query, but the template itself isn't otherwise connected to what the main query contains, that all happens before the template is loaded.

If you want to show content in a page aside from what is generated by the main query, you have to query for it yourself. See WP_Query in Codex for everything you need to know about creating queries in WordPress.

$args = array(
    'posts_per_page' => -1
);
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
        echo '<ul>';
    while ( $the_query->have_posts() ) {
        $the_query->the_post();
        echo '<li>' . get_the_title() . '</li>';
    }
        echo '</ul>';
} else {
    // no posts found
}
/* Restore original Post Data */
wp_reset_postdata();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.