0

I've created a custom post type with CPTUI and am trying to get the post-metadata to appear the same as on the front page. However, the post-metadata is not appearing, as if is missing.

the test site is http://50.87.248.66/~tulalipl/ the page with the custom type is http://50.87.248.66/~tulalipl/natosha-gobin/

The php to call the data is...

  <?php
    $post = array( 'post_type' => 'ngobin', 'posts_per_page' => '5'  );
    $loop = new WP_Query( $post );   
  ?>

     <?php while ( $loop->have_posts() ) : $loop->the_post();?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>

    <header class="entry-header">
        <?php
            if ( is_single() ) {
                the_title( '<h3 class="entry-title">', '</h3>' );
            } else {
                the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
            }
    if ( 'post' === get_post_type() ): ?>
            <div class="post-details">
                <i class="fa fa-user"></i><?php the_author(); ?>
                <i class="fa fa-clock-o"></i> <time><?php the_time('m/j/y g:i A'); ?></time>
                <i class="fa fa-folder"></i> <?php the_category(', ' ) ?>
                <i class="fa fa-tags"></i> <?php the_tags(); ?>
                <div class="post-comments-badge"><a href="<?php comments_link(); ?>"><i class="fa fa-comments"></i><?php comments_number( 0, 1, '%' ); ?></a>
                </div> <!-- post-comments-badge-->
                  <?php edit_post_link( 'Edit', '<i class="fa fa-pencil"></i>', '' ); ?>
                </div>



    <?php
        endif; ?>
    </header><!-- .entry-header -->
    <?php if ( has_post_thumbnail () ) {  // check for feature image ?>
        <div class="post-image">
              <?php the_post_thumbnail ();?>
        </div> <!-- ================ End Post Image ================= -->
        <?php } ?>
    <div class="post-excerpt">
        <?php if (is_single()) { 
        the_content(); 
        } else {
            the_excerpt();
        } ?>
    </div><!-- ================  End Post Excerpt  ================= -->

    <footer class="entry-footer">
        <?php the_language_of_puget_sound_entry_footer(); ?>
    </footer><!-- .entry-footer -->
</article><!-- #post-## -->


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

The template code is checking to see if the post type is post, and only displaying the post meta information if that is true:

if ( 'post' === get_post_type() ): ?>

Since the custom post type ngobin is being viewed, the above check returns false so the meta data is not displayed. The fix is as simple; change the post type check to ngobin:

if ( 'ngobin' === get_post_type() ): ?>
        <div class="post-details">
            <i class="fa fa-user"></i><?php the_author(); ?>
            <i class="fa fa-clock-o"></i> <time><?php the_time('m/j/y g:i A'); ?></time>
            <i class="fa fa-folder"></i> <?php the_category(', ' ) ?>
            <i class="fa fa-tags"></i> <?php the_tags(); ?>
            <div class="post-comments-badge"><a href="<?php comments_link(); ?>"><i class="fa fa-comments"></i><?php comments_number( 0, 1, '%' ); ?></a>
            </div> <!-- post-comments-badge-->
              <?php edit_post_link( 'Edit', '<i class="fa fa-pencil"></i>', '' ); ?>
            </div>
        </div>
<?php endif; ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.