Custom Post Type display on homepage
-
My site is currently using 2 custom post types.
On the home page, I want to pull up a list of all posts, whether of a custom type or not. However, I want to display them differently.For a default post, I would like to display the title & an excerpt, and for the custom post types I want to display their custom fields.
<?php while ( have_posts() ) : the_post(); ?> <a href = '<?php the_permalink(); ?>'><h2><?php the_title(); ?></h2></a> <p><em><?php the_excerpt(); ?></em></p> <p><em><?php echo(types_render_field("publish", array("arg1"=>"val1","arg2"=>"val2"))); ?> <?php echo(types_render_field("show", array("arg1"=>"val1","arg2"=>"val2"))); ?>, <?php echo(types_render_field("date", array("arg1"=>"val1","arg2"=>"val2")));?></em></p> <?php endwhile; ?>
Currently I just have this, which is displaying an excerpt and custom types for all post types, including the default post (So it displays as just a ‘,’ after the excerpt).
Basically I want to structure an if block to display the excerpt only if it’s NOT a custom post type, and display custom fields only if it IS a custom post type.
Seems simple enough, but I’ve been having difficulty.Any help is greatly appreciated ??
- The topic ‘Custom Post Type display on homepage’ is closed to new replies.