0

私は 2 つの投稿タイプを持っています。1 つはゲームで、もう 1 つは私が助けてもらったこのループに含めようとしている映画です。何を変更すればよいかわかりません。

<?php if ( have_posts() ) : ?>


    <?php /* Start the Loop */ ?>

    <?php
    $query = new WP_Query( array( 'tag__not_in' => array( 20 ) ) );/* Exclude Tag 20 (reviews)*/
    while( $query->have_posts() ):
    $query->the_post();

    get_template_part( 'content', get_post_format() );

    endwhile;

    ?>

<?php else : ?>

    <?php get_template_part( 'no-results', 'index' ); ?>

<?php endif; ?>

これらの投稿タイプをどこに含めますか?


編集: ループを更新しましたが、ページは空白/白です。私が持っているものは次のとおりです。

<?php if ( have_posts() ) : ?>


<?php /* Start the Loop */ ?>

<?php
$query = new WP_Query( array( 'post_type' => array( 'movies_cp','gaming_cp'), 'tag__not_in' => array( 20 )) )
while( $query->have_posts() ):
$query->the_post();

get_template_part( 'content', get_post_format() );

endwhile;

?>

<?php else : ?>

<?php get_template_part( 'no-results', 'index' ); ?>

<?php endif; ?>

ムービー カスタム投稿タイプ (カスタム投稿タイプ UI プラグインを使用):

register_post_type('movies_cp', array(  'label' => 'Movie Posts','description' => '','public' => true,'show_ui' => true,'show_in_menu' => true,'capability_type' => 'post','hierarchical' => false,'rewrite' => array('slug' => 'movies'),'query_var' => true,'exclude_from_search' => false,'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes',),'taxonomies' => array('category','post_tag',),'labels' => array (
  'name' => 'Movie Posts',
  'singular_name' => 'Movie Post',
  'menu_name' => 'Movie Posts',
  'add_new' => 'Add Movie Post',
  'add_new_item' => 'Add New Movie Post',
  'edit' => 'Edit',
  'edit_item' => 'Edit Movie Post',
  'new_item' => 'New Movie Post',
  'view' => 'View Movie Post',
  'view_item' => 'View Movie Post',
  'search_items' => 'Search Movie Posts',
  'not_found' => 'No Movie Posts Found',
  'not_found_in_trash' => 'No Movie Posts Found in Trash',
  'parent' => 'Parent Movie Post',
),) );
4

1 に答える 1

3

複数の投稿タイプの投稿を取得したいですか?はいの場合、以下はあなたを助けることができるコードです。

$query = new WP_Query( array( 'post_type' => array( 'gaming','movie'), 'tag__not_in' => array( 20 )) )

http://codex.wordpress.org/Class_Reference/WP_Query

于 2012-11-11T11:20:21.340 に答える