我添加了自定義的帖子類型字段名稱'Movies'。現在我已經完成了這些事情,它的工作很好,但問題是,(即,當我點擊任何電影時,它只顯示一個電影帖子(即,我點擊頭像電影它顯示我的頭像電影帖子,但當我點擊星際之門電影它顯示我的頭像電影帖子。請幫助它的一個大問題)任何人誰可以幫助我使這個代碼完全是我想要的。自定義文章類型小幫助?
在我的functions.php我添加驗證碼:
add_action('init', 'create_post_type');
function create_post_type() {
register_post_type('Movies',
array(
'labels' => array(
'name' => __('movie'),
'singular_name' => __('movie')
),
'public' => true,
'has_archive' => true,
)
);
}
然後在我的模板文件添加此,我想展示後:
<?php
$args = array('post_type' => 'movies', 'posts_per_page' => 1);
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();
?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<h1>
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a>
</h1>
<div class="entry-content">
<?php the_content(); ?>
</div>
</div>
<?php endwhile; ?>
我對這件事很陌生,所以請儘可能多地解釋我,我在哪裏粘貼或做什麼?
嗯,我已經改變這個代碼但沒有成功,我得到同樣的問題。我在自定義電影中添加的最後一部電影字段'電影'它只顯示我同樣的電影文章,如果我點擊任何電影。 我在代碼中添加了這個東西「'name'=> $ _GET ['movie']」,但沒有幫助,所以請告訴我,我該怎麼辦? – cinelink
你的鏈接是怎樣的? – Anonymous