This one’s an easy fix! The first argument in has_post_format()
is a string in the format post-format-{type}
, e.g. post-format-aside
, or post-format-gallery
, etc.
So, e.g., change this:
has_post_format( 'aside' , $post_id )
To this:
has_post_format( 'post-format-aside' , $post_id )
Wash, rinse, and repeat for all uses of has_post_format()
.
EDIT
Given your example code, I would even suggest another potential option, combining get_template_part()
and get_post_format()
.
If you create template part files entry-aside.php
and entry-gallery.php
, along with a default, entry.php
, then:
1) Move this code to entry-aside.php
(and remove unsupported parameters):
the_excerpt();
2) Move this code to entry-gallery.php
:
if ( has_post_thumbnail() ) {
// use the thumbnail ("featured image")
$thumb_id = get_post_thumbnail_id();
the_post_thumbnail( 'thumbnail' );
} else {
$attachments = get_children( array(
'post_parent' => get_the_ID(),
'post_status' => 'inherit',
'post_type' => 'attachment',
'post_mime_type' => 'image',
'order' => 'ASC',
'orderby' => 'menu_order ID',
'numberposts' => 1)
);
foreach ( $attachments as $thumb_id => $attachment )
echo wp_get_attachment_image($thumb_id, 'thumbnail' );
}
3) Move this code to entry.php
if ( $fluidtheme_options['fluid_post_content'] == "content" ) the_content(__('Continue Reading →', 'wptumble-fluid')); else the_excerpt();
4) Replace that entire if/else conditional block with this:
get_template_part( 'entry', get_post_format() );
Now, it might be overkill for your current use case – but the advantage is that, if in the future you decide to support other post format types, you simply have to add entry-{type}.php
, and your template will already be set up to support it! For example, if you add support for quotes, simply add entry-quote.php
, with whatever appropriate code, and you don’t have to change any existing code.