最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - get_post_format is not returning standard

programmeradmin1浏览0评论

I am using Video post format and Standard post format.

add_theme_support('post-formats', array('video'));

While displaying all the blog posts, I want to show different icons for video post format and standard post format.

$query = array(
'post_type'      => 'post',
'posts_per_page' => 12,
'tax_query'      => $cat_query_var,
'paged'          => $paged,
'meta_query'     => $cat_query_vars
);

$wedding_qry = new WP_Query($query);
if ($wedding_qry->have_posts()) :
while ($wedding_qry->have_posts()) : $wedding_qry->the_post();

    $post_format = get_post_format();
?>
    <div class="col-md-4">
        <div class="content">
            <a href="<?php the_permalink(); ?>">
                    <div class="icon">
                        <?php if ($post_format = 'video') { ?>
    <img src="<?php echo get_bloginfo("template_url") . '/img/video.png'; ?>" alt="video">
  <?php } elseif (!empty($icon_image)) { ?>
                            <img src="<?php echo $icon_image["url"]; ?>" alt="<?php echo get_image_alt(get_the_ID()); ?>">
                        <?php } else { ?>
                            <img src="<?php echo get_bloginfo("template_url") . '/img/ring.png'; ?>" class="ringimg">
                        <?php } ?>
                    </div>
            </a>
        </div>
    </div>

<?php $count++;
endwhile;

But $post_format always returns video. What am i doing wrong.

Please help.

发布评论

评论列表(0)

  1. 暂无评论