WordPress: is_single not applying to post types
Hi all,
Ive got a standard blog template that is using post types: gallery, video, audio, and quote, in addition to the standard. I have a content.php that instructs the handling of each type in general. For single post display, I have a template part loading that should handle what I think is all single posts, but in reality is only applying to standard single posts and excluding single gallery, video, audio and quote posts. (The content-single template assigns a “related posts” function and others that don’t display in a blog posts list, which i want visible on all single posts regardless of type)
I’ve tried is_single (‘post types’ ) ) and is_singular( array (‘post_type1’ etc) ) in addition to the standard is_single () ) ; …
I’ve been through the codex (http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page) and I’ve seen blog posts on how to assign different templates to different post types such as http://gabrieleromanato.name/wordpress-create-a-different-single-php-template-for-each-post-format/, but I’m the opposite: I want is_single to apply to all post types: standard, video, audio, gallery and quote. I tried the method suggested here WordPress Conditional if is_single about creating individual template parts for each post type (by making duplicates of content-single named single-video, single-audio etc) but that didn’t work either.
I know I’m dumb. Thanks in advance for any advice you might have.
<?php elseif (is_single( ) ) : ?>
<?php get_template_part( 'content-single'); ?>
<?php else : ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<div id="entry-category"><?php the_category(', '); ?></div>
<div id="entry-title"><?php the_title( sprintf( '<h1><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?></div><!--- .entry-title -->
<div id="entry-date"><?php the_time('l, jS F Y');?></div><!-- .entry-meta -->
</header><!-- .entry-header -->
<div class="entry-content">
<div class="post-header">
<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
the_content(); ?>
Because Post Type is not
is_single()
– it isis_singular()
You can read more about is HERE
for custom post types use
is_singular()