0

わかりました。メタ ボックスに選択メニューを追加しています。現在表示しているページを除いて、同じ投稿タイプの他のページを一覧表示したいと考えています。コードは次のとおりです。

<select id="page_redirect_select">
<option value="">Select a Page</option>
<?php   
$this_id = $post->ID;
$args = array('post_type' => 'custom-post', 'nopaging'  => true);
$query = new WP_Query( $args );
if($query->have_posts()) {
    while ($query->have_posts()) {
        $query->the_post();
        $query_id = $query->post->ID;
        if($this_id !== $query_id){
            echo "<option value='";
            echo the_permalink();
            echo "'>".get_the_title();
            echo "</option>\n";
        }
    }
}
wp_reset_postdata();
?>
<option value="other">Other URL</option>
</select>

今、$this_id を echo すると、94 になります。$query_id は 6 です。ただし、($this_id !== $query_id) の比較では、true が返されます! 何か案は?

4

1 に答える 1