【发布时间】:2013-10-15 15:05:26
【问题描述】:
我正在构建一个 wordpress 主题,我需要检查是否有任何帖子以某种帖子格式编写。
这就是我的 functions.php
中的内容add_theme_support( 'post-formats', array( 'image', 'link', 'quote', 'status', 'video', 'audio', 'gallery' ) );
页面模板文件中的这一小段代码。
if ( current_theme_supports( 'post-formats' ) ){
$post_formats = get_theme_support( 'post-formats' );
if ( is_array( $post_formats[0] ) ) {
foreach ($post_formats[0] as $post_format) {
echo '<a href="#">'.$post_format.'</a>';
}
}
}
所以,目前我将所有帖子格式显示为链接。我需要的是ONLY显示分配了该帖子格式的帖子。
示例:
如果没有指定帖子格式引用的帖子,则不要显示引用链接。
我尝试搜索网络但没有成功。有谁知道如何做到这一点?谢谢!
【问题讨论】:
标签: php wordpress wordpress-theming