I have looked at the WordPress codex trying to solve my problem. I tried this code:
<?php
/**
* Template Name: Page of Posts
*
*/
get_header(posts); ?>
<div id="container">
<div id="content" role="main">
<?php
$type = 'post';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'paged' => $paged,
'posts_per_page' => 20,
'caller_get_posts'=> 1
);
$temp = $wp_query; // assign orginal query to temp variable for later use
$wp_query = null;
$wp_query = new WP_Query($args);
?>
<?php
get_template_part( 'loop', 'index' );?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
But it just gives me a list of all my posts, they aren’t the intros with “read more”.
From WordPress 3.0 you don’t need to create a new header template file to just to show a different image. All you need to do is to specify the header you want in the pages ‘Featured Image’ section (found under the ‘Publish’ and ‘Page Attributes’ meta boxes on the edit pages screen).
Just makes it easy to set up any number of custom headers for each post/page you want without having to create header.php theme template files manually.
It’s more than just changing the header image. I have modified the theme some. On my “pages” I don’t have the horizontal navigation bar; I use a widget for navigation. However for the “posts” I want the top horizontal navigation bar. There are some other differences as well. That’s why I have a different header template.
ok I think I figured it out.
<?php
/**
* Template Name: Page of Posts
*/
get_header(posts); ?>
<div id="container">
<div id="content" role="main">
<?php
$cat = '';
$showposts = -1; // -1 shows all posts
$do_not_show_stickies = 1; // 0 to show stickies
$args=array(
'category__in' => $cat,
'showposts' => $showposts,
'caller_get_posts' => $do_not_show_stickies
);
$my_query = new WP_Query($args);
?>
<?php if( $my_query->have_posts() ) : ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php
//necessary to show the tags
global $wp_query;
$wp_query->in_the_loop = true;
?>
<?php
global $more;
$more = 0;
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-meta">
<?php twentyten_posted_on(); ?>
</div><!-- .entry-meta -->
<div class="entry-content">
<?php the_content('<div id=readmore>Read more...</div>'); ?>
</div>
<!--<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments ?', '1 Comment ?', '% Comments ?'); ?></p>-->
</div>
<?php endwhile; ?>
<?php else : ?>
<h3 class="center">Not Found</h3>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
It isn’t pretty but it seems to work.