0

I'm busy learning some basics behind Wordpress development and so far I'm getting on quite well. However, I've hit a stumbling block.

Firstly, my test site is; http://popcorn.canny-creative.com And, my reading settings are set as Wordpress to display "Your latest posts" on the homepage. Settings

If you check the link, you'll notice that "Hello World" and "Let's Get Chinese Food" posts have "posted by...posted on..." meta information, as well as Posted In at the bottom.

The problem is, the custom post type (movie_reviews) with Shawshank Redemption and The Dark Knight, don't show these same values.

I'm using Underscores as a starting point, and I think I've narrowed it down to template-tags.php being where this information is fetched from. Am I right in thinking the custom-post-type isn't included somehow?

Also, is this information "post-meta"? Or have I picked that up wrong?

Many thanks.

1 Answer 1

0

On a single custom post type (for example), you can see the post meta.

However on your homepage archive loop, you cannot because the theme uses a different template for this. Check out Template Hierarchy.

The "home" page in _s is governed by the "index.php" template. In which we see:

get_template_part( 'content', get_post_format() );

Since there aren't any custom post format templates for content (ie: content-gallery.php, content-quote.php, etc) we know to look at regular old content.php

The template for content.php looks like:

<?php
/**
 * @package _S
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <header class="entry-header">
        <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', '_S' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>

        <?php if ( 'post' == get_post_type() ) : ?>
        <div class="entry-meta">
            <?php _s_posted_on(); ?>
        </div><!-- .entry-meta -->
        <?php endif; ?>
    </header><!-- .entry-header -->

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
        <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
        <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', '_S' ) ); ?>
        <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', '_S' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    <footer class="entry-meta">
        <?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
            <?php
                /* translators: used between list items, there is a space after the comma */
                $categories_list = get_the_category_list( __( ', ', '_S' ) );
                if ( $categories_list && _s_categorized_blog() ) :
            ?>
            <span class="cat-links">
                <?php printf( __( 'Posted in %1$s', '_S' ), $categories_list ); ?>
            </span>
            <?php endif; // End if categories ?>

            <?php
                /* translators: used between list items, there is a space after the comma */
                $tags_list = get_the_tag_list( '', __( ', ', '_S' ) );
                if ( $tags_list ) :
            ?>
            <span class="sep"> | </span>
            <span class="tags-links">
                <?php printf( __( 'Tagged %1$s', '_S' ), $tags_list ); ?>
            </span>
            <?php endif; // End if $tags_list ?>
        <?php endif; // End if 'post' == get_post_type() ?>

        <?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
        <span class="sep"> | </span>
        <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', '_S' ), __( '1 Comment', '_S' ), __( '% Comments', '_S' ) ); ?></span>
        <?php endif; ?>

        <?php edit_post_link( __( 'Edit', '_S' ), '<span class="sep"> | </span><span class="edit-link">', '</span>' ); ?>
    </footer><!-- .entry-meta -->
</article><!-- #post-## -->

You should be able to see pretty clearly that the post meta function _s_posted_on() is wrapped in a conditional if ( 'post' == get_post_type() ) :. _s is usually meant to be directly customized (instead of child themed) so you'll want to go ahead and either remove or modify that conditional to meet your needs. Removing it will show the meta everywhere the content.php template is called. Or you can modify it so that it works for both posts and your review post type (I'm assuming here is called "movie-review", but change to suit):

if ( in_array( get_post_type(), array( 'post, 'movie_reviews' ) ) ) : 
3
  • Thank you very much @helgatheviking. Just one thing to note was the missing ' from post, – <?php if ( in_array( get_post_type(), array( 'post', 'movie_reviews' ) ) ) : ?>
    – Tony Hardy
    Commented Apr 18, 2014 at 15:10
  • Hi.. Is the '_S' value which can also found on Customizing with the filter, a literal value or just refer to a string of a domain as what's documented? (*Thanks..) Commented Aug 13, 2015 at 4:59
  • Testing my memory, but I believe the '_S' is the text domain for the Underscores theme. Commented Aug 13, 2015 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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