Here is my wordpress theme to check out(its not completely finished): http://benlevywebdesign.com/wordpress/

This is my first time working with php/wordpress and making themes so keep that in mind. I have an index.php, css, and a 960.css file and don't know about the other files that you can include.

In my theme I would like to have different styles for my posts based on the content of each post like for images and video links or audio links.

I want to first focus on a photo style where the photo will be big and large and not the size of a thumbnail or regular post image.

Once I learn how to have different styles I can add more on my own because that is just the css!

Here is my current loop code:

    <!-- ***** Post **** -->
    <div class="grid_2 alpha">
        <div class="date_banner">
            <div class="d"><!-- sidebar 1 --><?php the_time('d'); ?></div>
            <div class="m"><!-- sidebar 1 --><?php the_time('M'); ?></div>
            <div class="y"><!-- sidebar 1 --><?php the_time('Y'); ?></div>
        <div class="commentsnumber">
            <?php comments_number('No comment', '1 comment', '% comments'); ?>

    <div class="grid_10 omega">

      <div class="post">
        <div class="titlepostauthorimage">
            <div class="post-title">
                <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
            <div class="post-author-image">

            <div class="post-author">
                 <?php the_author_posts_link(); ?>
            <div class="post-image">
                <?php the_post_thumbnail( $size, $attr ); ?> 

        <div class="post-body">
            <?php the_content(); ?>
        <div class="post-meta">
            <?php the_category(', '); ?>
            <!-- post tags -->
    <div class="commentsarrow"> <?php wp_list_comments(); ?> </div>

        <!-- ***** END post ***** -->
    <?php endwhile; else: ?>
        <!-- In case no posts were found -->
            <div class="post-cf">Hmmm? Can't. Find. Post.
    <?php endif; ?>

Here is an example blog theme that is doing what I want(3rd post from the bottom) http://demo.kreativethemes.com/evolution/

I read about using the post_class() function and that I would need to create another php file for the post type, or that I could just code the mark up right into the loop if that's more what I prefer on this question CSS for Custom Post Types (and understood what they are doing but don't know how to actually do it)

I think I want to go with putting it right into the loop if that's not too complicated as I said earlier I don't know much about other files you can include.

  • It sounds like Post Formats would go a long way for you.
    – s_ha_dum
    Commented Dec 1, 2012 at 1:24

2 Answers 2


Depending on which 'types' you need, you might be looking for the Post Format functionality. It allows you to set posts as standard, quotes, galleries, etc (sort of like Tumblr). To activate it, simply toss this into your theme (probably functions.php):

add_theme_support( 'post-formats', array( 'aside', 'gallery', 'quote' ) );

Then, in your templates, you've got some options. You can either use conditionals to go wild in single.php, or you can make PHP files for each post format. Inside single.php, you'd want something like this:

get_template_part( 'content', get_post_format() );

Which will check for the post format and load the appropriate file. That way, a gallery formatted post can easily have something like:


already inserted. The templates will just know when a gallery is being displayed and automatically show images.

Is that what you're after?

  • Yes this is what I am after but I don't have a functions.php file and I am new to this whole php/wordpress thing so I only understand what you are saying but have no idea how to actually do it. Commented Nov 2, 2012 at 17:46
  • If i am just learning php/wordpress would separate .php files be easier to understand/work with? Commented Nov 2, 2012 at 17:48
  • If you're new, using separate PHP files would definitely keep things cleaner. What theme are you using? It should have a functions.php file, unless you are using a child theme, in which case we can simply create the file ourselves.
    – clark
    Commented Nov 2, 2012 at 17:53
  • I am using a theme that I'm creating myself for my class and you can see it here: benlevywebdesign.com/wordpress (its not completely finished but I'm getting there) So I guess that means I have total control over everything! Commented Nov 2, 2012 at 17:58
  • That means you can add a functions.php file in your theme folder. All you need to do is put <?php at the beginning of the file, and you're good to go!
    – Jen
    Commented Nov 2, 2012 at 17:59

Use custom post formats. Would pretty much do exactly what you want!


Sorry, I forgot to add that this would be a better practice to do. You could keep the divs with the grid classes in the loop, but then use get_template_part('content', get_post_format()); within that div.

That will load the template file 'content-video.php' if the post format was a video. In there it's business as usual with markup and php.

In the 'content-video.php' or whatever post type it is, you can load your CSS classes like usual.

Here's some more detail:

In functions.php file:

add_theme_support( 'post-formats', array( 'video', 'gallery' ) );

Then in your index.php file (the one with the loop), you could do this:

`while ( have_posts() ) : the_post(); get_template_part('content', get_post_format());`

That will get you the right content file, ie; content.php or content-video.php, etc.

Then in content-video.php, if you're displaying a youtube video for example:


With this in mind, you would have the following files:

functions.php - you'll need this sooner or later so it won't hurt to create it

content.php - this will have the markup specific to the content of a post. This is the generic one.

content-video.php - this is where you would put code that is different from all other content. Or in other words, specific to video.php

The index.php more or less just sets up the loop Hope this helps!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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