Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created March 25, 2016 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save generatepress/4084f46ab0bd1c9f8c9e to your computer and use it in GitHub Desktop.
Save generatepress/4084f46ab0bd1c9f8c9e to your computer and use it in GitHub Desktop.
Add post meta (generate_entry_meta() and generate_posted_on()) to more post types
if ( ! function_exists( 'generate_entry_meta' ) ) :
/**
* Prints HTML with meta information for the categories, tags.
*
* @since 1.2.5
*/
function generate_entry_meta()
{
$categories = apply_filters( 'generate_show_categories', true );
$tags = apply_filters( 'generate_show_tags', true );
$comments = apply_filters( 'generate_show_comments', true );
if ( 'post' == get_post_type() || 'portfolio' == get_post_type() ) {
$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
if ( $categories_list && $categories ) {
printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Categories', 'Used before category names.', 'generatepress' ),
$categories_list
);
}
$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ) );
if ( $tags_list && $tags ) {
printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
_x( 'Tags', 'Used before tag names.', 'generatepress' ),
$tags_list
);
}
}
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && $comments ) {
echo '<span class="comments-link">';
comments_popup_link( __( 'Leave a comment', 'generatepress' ), __( '1 Comment', 'generatepress' ), __( '% Comments', 'generatepress' ) );
echo '</span>';
}
}
endif;
if ( ! function_exists( 'generate_post_meta' ) ) :
add_action( 'generate_after_entry_title', 'generate_post_meta' );
function generate_post_meta()
{
if ( 'post' == get_post_type() || 'product' == get_post_type() ) : ?>
<div class="entry-meta">
<?php generate_posted_on(); ?>
</div><!-- .entry-meta -->
<?php endif;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment