WordPress.org

Support

Support » Themes and Templates » [Resolved] Format custom post types on homepage

[Resolved] Format custom post types on homepage

  • Walton
    Participant

    @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)
  • keesiemeijer
    moderator

    @keesiemeijer

    Try it with:

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

    Walton
    Participant

    @walton

    Oh yeah, that makes sense. Thanks a lot.

    Walton
    Participant

    @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 ‘[Resolved] Format custom post types on homepage’ is closed to new replies.