SOHO建站

标签: 判断是否有相册

共找到相关结果约1个

WP根据文章ID判断是否有相册并调用

根据wordpress文章ID判断是否有相册并调用,不废话直接上代码,在需要显示的位置调用下面代码即可。

$post_id = 88;
$has_gallery = ( count( get_post_galleries( $post_id, false ) ) > 0 );
if ( $has_gallery ) {
    echo "This post has a gallery.";
} else {
    echo "This post does not have a gallery.";
}