SHould I Use a Wordpress 3.0 Custom Post Type?
I am coding a wordpress theme for a magazine. One aspect of the site, is that the homepage is static, and it features the current issue of the magazine in one area of the homepage. I need help figuring out the most practical way of replacing content for the most recent issue on the homepage.
Basically, every month, an image, as well as a title and a short paragraph of text will change on the homepage. My homepage is a static page (from a template). I would like the client to be able to change the picture/text from the back end of wordpress. That said, is the best way to go about this is to write a custom post type?
This is unrelated to the blog (posts section). There is probably a very simple way of going about this. Any ideas?
Solutions
YES! Custom Post types was the solution. The answer is fully outlined here:link text
Basically, I added this to my functions. php file :
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type( 'current_issue',
array(
'labels' => array(
'name' => __( 'Current Issues' ),
'singular_name' => __( 'Current Issue' )
),
'public' => true,
'exclude_from_search' => true,
'supports' => array( 'title', 'editor', 'thumbnail' ),
)
);
}
And then added this into my homepage. php file :
<?php $loop = new WP_Query( array( 'post_type' => 'current_issue', 'posts_per_page' => 1 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_post_thumbnail( 'current-issue' ); ?>
<?php the_title( '<h2><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
<div class="readmore" style="margin-top:4px">
<a href="#">Read More</a>
</div>
<?php the_content(); ?>
<?php endwhile; ?>
It worked perfectly!