• Resolved Walton

    (@walton)


    I’m trying to make custom post types display different on my blog’s main page. I was trying to use this:

    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfloat <?php get_post_type() ?>">

    But that isn’t doing anything.
    Is there any way to change the post class for different custom post types?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Try it with:

    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfloat <?php echo get_post_type(); ?>">

    Thread Starter Walton

    (@walton)

    Oh yeah, that makes sense. Thanks a lot.

    Thread Starter Walton

    (@walton)

    Quick word of advice for anyone who wants to use this trick, you’ll end u with posts on your homepage with class “post” which your theme might already be using somewhere else.

    So I did this:

    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfloat <?php echo get_post_type(); ?>style">

    so my classes on the homepage end up being

    poststyle
    lessonstyle
    etc….

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Format custom post types on homepage’ is closed to new replies.