Custom Post Template

Hi,

I am setting up a template for a custom post type, the post title and custom fields I created appear but not the content. I am using <?php the_content( ); ?>, but it doesn’t bring the content. Is there something else I am supposed to be using?

I using the Twenty Ten theme, not sure if that helps.

Thanks,

Dana

  • tad
    • Site Builder, Child of Zeus

    Here’s the template info:

    <h1 class="entry-title"><?php the_title(); ?></h1> <br />

    <strong>Date:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e4175036d7f9', true ); ?> <br />
    <strong>Time:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41752117073', true ); ?> <br />
    <strong>Location:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e417544f2874', true ); ?> <br />
    <strong>URL:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41758e091ac', true ); ?> <br />
    <div class="content"><?php the_content(); ?></div>

    Thought it may help to see this too.

  • tad
    • Site Builder, Child of Zeus

    That bottom part has been happening since I added the custom post type, no idea where that came from. It doesn’t appear in different themes, so I’ll leave designer to figure that out since that was setup before I added post type. If you look at any page, even index pages it’s on all of them.

    Here’s the everything:

    <?php
    /**
    * The Template for displaying all event posts types.
    */

    get_header(); ?>

    <div id="container">
    <div id="content" role="main">

    <h1 class="entry-title"><?php the_title(); ?></h1> <br />

    <strong>Date:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e4175036d7f9', true ); ?> <br />
    <strong>Time:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41752117073', true ); ?> <br />
    <strong>Location:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e417544f2874', true ); ?> <br />
    <strong>URL:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41758e091ac', true ); ?> <br />
    <br />
    <div class="entry-content"><?php the_content(); ?></div>

    </div><!-- #content -->
    </div><!-- #container -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  • tad
    • Site Builder, Child of Zeus

    I don’t think there is a sidebar issue. The content was there before with the default loop code when I copy the template, but I want the order to be different and include the custom fields after title, but before content. This is what is was before and worked fine:

    <?php
    /**
    * The Template for displaying all single posts.
    *
    * @package WordPress
    * @subpackage Twenty_Ten
    * @since Twenty Ten 1.0
    */

    get_header(); ?>

    <div id="container">
    <div id="content" role="main">

    <?php
    /* Run the loop to output the post.
    * If you want to overload this in a child theme then include a file
    * called loop-single.php and that will be used instead.
    */
    get_template_part( 'loop', 'single' );
    ?>

    </div><!-- #content -->
    </div><!-- #container -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    The loop includes:

    <?php
    /**
    * The loop that displays a single post.
    *
    * The loop displays the posts and the post content. See
    * http://codex.wordpress.org/The_Loop to understand it and
    * http://codex.wordpress.org/Template_Tags to understand
    * the tags used in it.
    *
    * This can be overridden in child themes with loop-single.php.
    *
    * @package WordPress
    * @subpackage Twenty_Ten
    * @since Twenty Ten 1.2
    */
    ?>

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <h1 class="entry-title"><?php the_title(); ?></h1>

    <div class="entry-content">
    <?php the_content(); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->

    <?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries ?>
    <div id="entry-author-info">
    <div id="author-avatar">
    <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentyten_author_bio_avatar_size', 60 ) ); ?>
    </div><!-- #author-avatar -->
    <div id="author-description">
    <h2><?php printf( esc_attr__( 'About %s', 'twentyten' ), get_the_author() ); ?></h2>
    <?php the_author_meta( 'description' ); ?>
    <div id="author-link">
    <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
    <?php printf( __( 'View all posts by %s <span class="meta-nav">?</span>', 'twentyten' ), get_the_author() ); ?>
    </a>
    </div><!-- #author-link -->
    </div><!-- #author-description -->
    </div><!-- #entry-author-info -->
    <?php endif; ?>
    </div><!-- #post-## -->

    <?php comments_template( '', true ); ?>

    <?php endwhile; // end of the loop. ?>

    All I want is Title, which is coming through with: <h1 class="entry-title"><?php the_title(); ?></h1>

    The custom fields, which is also coming through with:

    <strong>Date:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e4175036d7f9', true ); ?> <br />
    <strong>Time:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41752117073', true ); ?> <br />
    <strong>Location:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e417544f2874', true ); ?> <br />
    <strong>URL:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41758e091ac', true ); ?> <br />
    <br />

    And then content which should work with:

    <div class="entry-content">
    <?php the_content(); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->

    I don’t understand why it’s not pulling the content. Is there something I missed?

  • Philip John
    • DEV MAN’s Apprentice

    What’s the plugin that adds those sharing buttons?

    Can you disable that? That plugin is obviously hooking into the_content() but that function isn’t printing the content which suggests to me that the plugin is replacing the content rather than adding itself to the content.

    Phil

  • tad
    • Site Builder, Child of Zeus

    Hey Phil,

    That’s the sharedaddy plugin. The content wasn’t displaying before that either. I removed the icons form appearing on events. A post type is the same content call as a regular post, right? And since it was working before and the title is coming through it seems I am missing something. Not sure what though.

    Thanks!

  • tad
    • Site Builder, Child of Zeus

    Thanks Phil,

    Here's the single-events.php template:

    <?php
    /**
    * The Template for displaying all event posts types.
    */

    get_header(); ?>

    <div id=&quot;container&quot;>
    <div id=&quot;content&quot; role=&quot;main&quot;>

    <h1 class=&quot;entry-title&quot;><?php the_title(); ?></h1> <br />

    <strong>Date:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e4175036d7f9', true ); ?> <br />
    <strong>Time:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41752117073', true ); ?> <br />
    <strong>Location:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e417544f2874', true ); ?> <br />
    <strong>URL:</strong> <?php echo get_post_meta( $post->ID, '_ct_text_4e41758e091ac', true ); ?> <br />
    <br />
    <div class=&quot;entry-content&quot;><?php the_content(); ?></div>

    </div><!-- #content -->
    </div><!-- #container -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    The first one I used above the loop-single.php directly from the TwentyTen theme, no changes.

    Attached is a list of all template files in child theme.

  • Philip John
    • DEV MAN’s Apprentice

    Yep, thought so (I should have spotted this sooner!) You’re basically missing the loop, like this;

    Insert this before line 10 of single-events.php:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    Insert this after line 29 of single-events.php:

    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>

    That *should* sort it.

    Phil

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.