Adding custom post types to blog.
-
Hello – I have a blog which displays the latest 6 “posts”, which is great, but I’d also like it to show the latest “recipes” which is a custom post type on my website.
Just be clear, I want the latest 6 blog posts, whether that’s a post or recipe to be shown.
This is the code I currently have on my index.php. But it only shows “posts”, any idea how to add “recipes” to this too?
<div id="left-area" class="clearfix"> <?php if (have_posts()): while (have_posts()) : the_post(); $post_type = get_post_type( $post->ID ); if($post_type = 'recipe') { get_template_part( 'inc/recipe-post' ); } else { get_template_part( 'inc/standard-post' ); } endwhile; else : ?> <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> <h2 class="post-title"><?php _e('No Post Found !', 'FoodRecipe') ?></h2> </div><!-- end of post div --> <?php endif; ?> <?php // Pagination theme_pagination( $wp_query->max_num_pages); ?> </div>
Thank you
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Adding custom post types to blog.’ is closed to new replies.