custom page template for blog page
-
I think I’ve confused myself by spending too much time on this.
I’ve set up some body classes that control the page layout, so for example <body class=”2-sidebars-left”> and this is controlled by a drop down meta box field in the pages write panel.
Now, this works fine for all pages except the blog page. This is because I set a static page for ‘Home’ and I set a ‘blog’ page to be the ‘posts page’. It then uses index.php and ignores my custom field settings or page template.
To work around this, I created a new page template with a WP_Query<?php $temp = $wp_query; $wp_query= null; ?> <?php $wp_query = new WP_Query(); ?> <?php $wp_query->query('posts_per_page=5'.'&paged='.$paged); ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post() ?>
…the loop…
<?php $wp_query = null; $wp_query = $temp;?>
I got the code from here :https://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/It works, but I’m wondering if it’s the best way to do it, and if it doesn’t have any side effects or something.
thanks for any suggestions
Paul
- The topic ‘custom page template for blog page’ is closed to new replies.