3

カスタム投稿タイプの条件付きクエリを作成しようとしています。ただし、特定の投稿に関連する必要があります。たとえば、すべてのプロジェクトで機能する現在のコードがあります。

<?php if ('project' == get_post_type() ) {  ?> 
// Get content 
<?php } ?>

ただし、ID 75 で特定のプロジェクトを指定できるようにする必要があります。これは可能ですか?

どんな助けでも大歓迎です。

乾杯、

4

3 に答える 3

1
if($post->post_type == 'type your post type here' ) : 
  //Get Content

endif;

これは機能しています...

于 2014-08-27T08:44:44.867 に答える
0

get_the_ID()LOOP 内で関数を使用できます:
http://codex.wordpress.org/Function_Reference/get_the_ID

<?php if ('project' == get_post_type() && get_the_ID() == 75) {  ?> 
// Get content 
<?php } ?>
于 2012-04-14T06:52:19.230 に答える