我希望我的主页位于此网页上:http://goodbyeboringlife.com/以显示我最新的任何类别的博文。
现在我正在使用此代码:
<div id='cssmenu'>
<ul>
<?php
$args = array(
'posts-per-page' => 10,
'cat' => 11,
'order' => 'DESC'
);
query_posts( $args );
if (have_posts()) :
while (have_posts()) : the_post();
echo "<div class='post-loop-image'>";
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
echo "</div>";
echo "<span class='post_title'>" . the_title() . "</span>";
endwhile;
endif;
wp_reset_query();
?>
</ul>
</div>
它看起来我想要它,我稍后会用CSS调整它,但代码缺少实际帖子的链接。我不知道如何在代码中实现它。
答案 0 :(得分:0)
<div id='cssmenu'>
<ul>
<?php
$args = array(
'posts-per-page' => 10,
'cat' => 11,
'order' => 'DESC'
);
query_posts( $args );
if (have_posts()) :
while (have_posts()) : the_post();
echo "<div class='post-loop-image'>";
if ( has_post_thumbnail() ) {
the_post_thumbnail();
}
echo "</div>";
echo "<a href='".the_permalink()."'"> <span class='post_title'>" . the_title() . "</span></a>";
endwhile;
endif;
wp_reset_query();
?>
</ul>
</div>
这会在帖子标题上生成一个链接
答案 1 :(得分:0)
用以下代码替换标题的代码块:
echo "<a href='" . the_permalink() . "'"> <span class='post_title'>" . the_title() . "</span></a>";
the_permalink()是WordPress的内置函数,可检索帖子链接