任何人都可以帮助我制作出我想要的代码
<div id="container">
<div class="clearfix"></div>
<?php $args = array(
'post_type' => 'movies',
'numberposts' => -1,
'order' => DESC ); $myquery = new WP_Query($args);
if($myquery->have_posts()) :
while($myquery->have_posts()) :
$myquery->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; endif; ?>
</div>
<?php include(TEMPLATEPATH . '/sidebar_single.php'); ?>在这段代码中,当我点击任何帖子时,我得到了所有的帖子,在single-movies.php上,它显示了所有10个帖子。但我只需要一个电影帖子,我点击。如果你认为这是错误的,请给我建议,因为我对此一无所知。
提前感谢库马尔
发布于 2011-09-17 01:09:17
怎么样
在你的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; ?>希望这能有所帮助。更多信息here
马蒂
https://stackoverflow.com/questions/7445806
复制相似问题