如果“画廊”是一个类别,您可以编辑您的single.php
模板并使用is_category()
:
<?php if ( in_category('gallery') ) : ?>
<!-- Single post style for gallery posts -->
<?php else: ?>
<!-- Normal single post style -->
<?php endif; ?>
如果它是自定义帖子类型,您可以在条件中使用get_post_type()
并single.php
使用其结果,例如
<?php
$post_type = get_post_type( $post->ID );
if ( $post_type == 'gallery' ): ?>
<!-- Single post style for gallery posts -->
<?php else: ?>
<!-- Normal single post style -->
<?php endif; ?>
如果是帖子格式,请使用get_post_format()
,例如
<?php
$post_format = get_post_format( $post->ID );
if ( $post_format == 'gallery' ): ?>
<!-- Single post style for gallery posts -->
<?php else: ?>
<!-- Normal single post style -->
<?php endif; ?>