2010-12-03 4 views

答えて

1
$siblings = get_posts(array(
    'exclude'  => array($post->ID), 
    'post_type' => $post->post_type, 
    'post_parent' => $post->post_parent, 
    'numberposts' => 1 // we're only checking if there ARE siblings, so save a little memory 
)); 

$is_only_child = empty($siblings); 
+0

動作していないようです。私はちょうど結果をエコーし​​、何もエコーしていないように見えます($ is_only_child){echo 'yes'; } – ApPeL

+0

どこにこのコードを使用していますか? '$ post'グローバルは利用可能ですか? 'print_r($ siblings)'の場合はどうなりますか? – TheDeadMedic

関連する問題