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!

Tags: PHP / Wordpress / Themes

Similar questions

How to make laravel and wordpress to make use of single user table (Wordpress should use laravel users table)
I am trying to merge Laravel and Wordpress together in one project. The way I want it to work is, for Laravel to handle the Database Interactions and complex iterations going on on the site, while Wordpress is used to handle the static contents, pages and all. Using this approach, I want both of them to share a users table for login on both ends. I...
what is the real use of __return_empty_array in wordpress and when should we use it?
As I have started learning wordpress plugin developement recently but i can't understand the function __return_empty_array. It returns an array but when should we really use it.
When to use the Filesystem API? Should I use it at all?
I'm wondering when it is recommended to use the Filesystem API, and whether it's useful at all? WordPress seems a little inconsistent when it comes to Filesystem API usage, it uses the API only in a few places when uploading and unpacking files, and that doesn't make much sense to me, I mean, where's to point in using it at all when there are a lot...
Should I use template files or just use conditional tags in index.php?
I am building a theme that has very few differences between templates. Right now I have it set up more or less like this: Looking at this setup, I realized that I could do something like this: I like this method for the same reason I like template parts - code that would have been repeated is now in only one place. If I decide to change the overall...
Should I use custom post types or a custom database tables for plugin development?
I'm fairly new to writing wordpress plugins, but I've jumped in the deep end already and I want to make sure I'm doing it "right" on my upcoming big project. I'm going to be heavily extending wordpress into a pretty big web app and want to keep my data structures as native as possible to rely on the wordpress framework, but I don't know if it is be...
Iterate through custom post type by custom taxonomy type? (Ordering wordpress posts by category, or displaying custom post type by taxonomy term)
I want to have a page that shows all posts, separated by category. The idea is to get the categories, and then iterate through all posts for each category. The problem is complicated by the fact that I want to iterate through all posts of a given custom type, using a custom taxonomy as the categories. (Running Wordpress 3) In my functions.php, my c...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.