WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Format custom post types on homepage (4 posts)

  1. Walton
    Member
    Posted 3 years ago #

    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?

  2. keesiemeijer
    moderator
    Posted 3 years ago #

    Try it with:

    <?php while (have_posts()) : the_post(); ?>
    <div class="clearfloat <?php echo get_post_type(); ?>">
  3. Walton
    Member
    Posted 3 years ago #

    Oh yeah, that makes sense. Thanks a lot.

  4. Walton
    Member
    Posted 3 years ago #

    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....

Topic Closed

This topic has been closed to new replies.

About this Topic