我正在制作一个 wordpress 主题。现在我被一些东西困住了。我想在单个帖子的循环中显示来自同一类别的帖子。“Aktuelt for deg”是应显示同一类别的帖子的位置。实时预览。这是我的代码:
<?php get_header(); ?>
<div id="hold" class="clearfix">
<div id="left">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class="entry">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="author">Skrevet av <?php the_author(); ?></div>
<?php the_content(); ?>
</div>
<div class="comment-template">
<?php comments_template(); ?>
</div>
</div>
<div id="right">
<div class="search">
<form action="<?php echo home_url( '/' ); ?>" method="get">
<input type="text" value="Skriv her for å søke.." name="s" id="s" onblur="if (this.value == '') {this.value = 'Skriv her for å søke..';}"
onfocus="if (this.value == 'Skriv her for å søke..') {this.value = '';}">
</form>
<script type="text/javascript">
$(".search").keypress(function(ev){
if (ev.keyCode == 13) {
$("form")[0].submit();
}
});
</script>
</div>
<div class="box">
<div class="heading">
<h1>Aktuelt for deg</h1>
</div>
<ul>
<?php query_posts('posts_per_page=5' . '&orderby=rand');
while ( have_posts() ) : the_post();
echo '<li><div class="borderline"><a href="';
the_permalink();
echo '">';
the_title();
echo '</a></div><author>Skrevet av ';
the_author();
echo '</author></li>';
endwhile;
// Reset Query
wp_reset_query();
?>
</ul>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
<?php get_footer(); ?>