Working to create a custom wordpress theme with custom post types:
I have added custom post types (via the plugin custom post UI) and custom fields (via advanced custom fields). The custom post is correctly displaying in the new template page created (single-custom.php). So the individual custom posts are displaying exactly as I would like.
The problem however is that on the homepage only the title is displaying.
What I've done:
1) I've added the following code to allow new post types to be pulled into the feed on the homepage/blog feed via the functions.php:
add_filter( 'pre_get_posts', 'my_get_posts' );
function my_get_posts( $query ) {
if ( ( is_home() && $query->is_main_query() ) || is_feed() )
$query->set( 'post_type', array( 'post', 'custom' ) );
return $query;
Thanks to Justin Tadlock for this
2) I've created a custom content page content-custom.php and amended the index loop to call that template:
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
get_template_part( 'content', 'custom', get_post_format() );
?>
<?php endwhile; ?>
My homepage is still only displaying the titles of my custom posts and not the full content as I hope. The problem has something to do with the call of the_content in the content-custom.php but I can't find the issue as I am still familiarizing myself with wordpress. The relevant code for the content-custom.php is as follows:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
//The title below is displayed correctly
<h1 class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
</header><!-- .entry-header -->
// The problem begins below. The entry-content div is created but is empty and is not pulling any content from the custom post through the_content call.
<div class="entry-content">
<?php the_content(); ?>
</div><!-- .entry-content -->