WordPress - 单个帖子模板 - 显示所有帖子
我制作了一个自定义模板(用于单个帖子),但它显示所有帖子,而不是我之前点击过的帖子。
这是我的模板:
<?php
query_posts( 'post_type=catalogue');
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="header">
<h1><?php echo get_the_term_list($post->ID, 'theme', '', '', ''); ?></h1>
</div>
<div class="main">
<div class="categorie-title"><?php echo get_the_term_list($post->ID, 'theme', '', '', ''); ?></div>
<div id="article-header">
<h2><?php the_title(); ?></h2>
<h3><?php echo get_the_term_list($post->ID, 'realisation', 'Un documentaire réalisé par ', ', ', '.'); ?></h3>
<div class="duree"><?php echo get_post_meta($post->ID, 'Duree', true); ?></div>
</div>
<div class="gallerie-couvertures">
<?php /*
$uploads = wp_upload_dir();
echo '<ul>';
if ($dir = opendir($uploads['basedir'].'/images-produits')) {
$images = array();
while (false !== ($file = readdir($dir))) {
if ($file != "." && $file != "..") {
echo '<li><img src="';
echo $uploads['baseurl'].'/images-produits/'.$file;
echo '" alt="" /></li>
';
}
}
closedir($dir);
}
echo '</ul>';
*/?>
</div>
<div class="section">
<h2><?php the_title(); ?></h2>
<h3><?php echo get_the_term_list($post->ID, 'realisation', 'Un documentaire réalisé par ', ', ', '.'); ?></h3>
<div class="content">
<?php the_content(); ?>
</div>
<ul id="film-description">
<li><span>Genre: </span><?php echo get_the_term_list($post->ID, 'genre', ' ',',', '.'); ?></li>
<li><span>Réalisation: </span><ul><?php echo get_the_term_list($post->ID, 'realisation', '<li>', '</li><li>', '</li>'); ?></ul></li>
<li><span>Co-production: </span><ul><?php echo get_the_term_list($post->ID, 'co-production', '<li>', '</li><li>', '</li>'); ?></ul></li>
<li><span>Année: </span><?php echo get_the_term_list($post->ID, 'date-de-sortie'); ?></li>
<li><span>Couleurs: </span><?php echo get_the_term_list($post->ID, 'couleurs', '', ' - ', ''); ?></li>
<li><span>Distribution: </span><?php echo get_the_term_list($post->ID, 'distribution', '', ', ', ''); ?></li>
</ul>
</div>
<div class="section">
<h3 class="uppercase">Extrait</h3>
<?php echo get_the_term_list($post->ID, 'extrait'); ?>
<div class="movie-preview-description">
<h3><span><?php the_title(); ?></span> (trailer)</h3>
<p><?php echo get_the_term_list($post->ID, 'realisation', 'Un documentaire réalisé par ', ', ', ''); ?> - <?php echo get_post_meta($post->ID, 'Duree', true); ?> </p>
<p><?php echo get_the_term_list($post->ID, 'date-de-sortie'); ?> - <?php echo get_the_term_list($post->ID, 'distribution', '', ', ', ''); ?></p>
</div>
<div class="social-links">
<h4>Partagez</h4>
<ul>
<?php $args = array(
'orderby' => 'id',
'order' => 'ASC',
'category_name' => 'Social') ?>
<?php $socials = get_bookmarks($args);
foreach ($socials as $value) {
echo '<li><a href="'.$value->link_url.'" class="'.$value->link_name.'" target="_blank">'.$value->link_name.'</a></li>';
}
?>
</ul>
</div>
<div class="voir-vodeo">
<h4>Regarder sur VODEO</h4>
<a href="<?php echo get_post_meta($post->ID, 'VODEO', TRUE);?>" class="vodeo" target="_blank" >Vodeo</a>
</div>
</div>
</div>
<?php endwhile;// End the loop. Whew. ?>
<?php wp_reset_query();?>
我想,我错过了循环的一些东西,有什么想法吗?
i've make a custom template (for single post), but it display all the posts, not the one i've been clicking on before.
here is my template :
<?php
query_posts( 'post_type=catalogue');
if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div class="header">
<h1><?php echo get_the_term_list($post->ID, 'theme', '', '', ''); ?></h1>
</div>
<div class="main">
<div class="categorie-title"><?php echo get_the_term_list($post->ID, 'theme', '', '', ''); ?></div>
<div id="article-header">
<h2><?php the_title(); ?></h2>
<h3><?php echo get_the_term_list($post->ID, 'realisation', 'Un documentaire réalisé par ', ', ', '.'); ?></h3>
<div class="duree"><?php echo get_post_meta($post->ID, 'Duree', true); ?></div>
</div>
<div class="gallerie-couvertures">
<?php /*
$uploads = wp_upload_dir();
echo '<ul>';
if ($dir = opendir($uploads['basedir'].'/images-produits')) {
$images = array();
while (false !== ($file = readdir($dir))) {
if ($file != "." && $file != "..") {
echo '<li><img src="';
echo $uploads['baseurl'].'/images-produits/'.$file;
echo '" alt="" /></li>
';
}
}
closedir($dir);
}
echo '</ul>';
*/?>
</div>
<div class="section">
<h2><?php the_title(); ?></h2>
<h3><?php echo get_the_term_list($post->ID, 'realisation', 'Un documentaire réalisé par ', ', ', '.'); ?></h3>
<div class="content">
<?php the_content(); ?>
</div>
<ul id="film-description">
<li><span>Genre: </span><?php echo get_the_term_list($post->ID, 'genre', ' ',',', '.'); ?></li>
<li><span>Réalisation: </span><ul><?php echo get_the_term_list($post->ID, 'realisation', '<li>', '</li><li>', '</li>'); ?></ul></li>
<li><span>Co-production: </span><ul><?php echo get_the_term_list($post->ID, 'co-production', '<li>', '</li><li>', '</li>'); ?></ul></li>
<li><span>Année: </span><?php echo get_the_term_list($post->ID, 'date-de-sortie'); ?></li>
<li><span>Couleurs: </span><?php echo get_the_term_list($post->ID, 'couleurs', '', ' - ', ''); ?></li>
<li><span>Distribution: </span><?php echo get_the_term_list($post->ID, 'distribution', '', ', ', ''); ?></li>
</ul>
</div>
<div class="section">
<h3 class="uppercase">Extrait</h3>
<?php echo get_the_term_list($post->ID, 'extrait'); ?>
<div class="movie-preview-description">
<h3><span><?php the_title(); ?></span> (trailer)</h3>
<p><?php echo get_the_term_list($post->ID, 'realisation', 'Un documentaire réalisé par ', ', ', ''); ?> - <?php echo get_post_meta($post->ID, 'Duree', true); ?> </p>
<p><?php echo get_the_term_list($post->ID, 'date-de-sortie'); ?> - <?php echo get_the_term_list($post->ID, 'distribution', '', ', ', ''); ?></p>
</div>
<div class="social-links">
<h4>Partagez</h4>
<ul>
<?php $args = array(
'orderby' => 'id',
'order' => 'ASC',
'category_name' => 'Social') ?>
<?php $socials = get_bookmarks($args);
foreach ($socials as $value) {
echo '<li><a href="'.$value->link_url.'" class="'.$value->link_name.'" target="_blank">'.$value->link_name.'</a></li>';
}
?>
</ul>
</div>
<div class="voir-vodeo">
<h4>Regarder sur VODEO</h4>
<a href="<?php echo get_post_meta($post->ID, 'VODEO', TRUE);?>" class="vodeo" target="_blank" >Vodeo</a>
</div>
</div>
</div>
<?php endwhile;// End the loop. Whew. ?>
<?php wp_reset_query();?>
I think, i've miss something with the loop, any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我发现问题了...我不需要指定 post_type 是什么,因为我点击了它。我不需要任何查询,我只是删除了这个:
query_posts('post_type=catalogue');。
Well, i find the problem... I don't need to specify what post_type is, because i click on it. I don't need any query, i ve just delete this :
query_posts( 'post_type=catalogue');.