首先,我很抱歉我的英语不好。
好的,我在我的worpdress中的single.php中使用此代码,它会在水平上发布
<?php
// Show a selected number of posts per row
$posts_per_row = 5;
$posts_per_page = 20;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => $posts_per_page,
'paged' => $paged,
);
query_posts($args);
if (have_posts()) {
while (have_posts()) {
the_post();
if ((++$post_counter % $posts_per_row) == 1 || $posts_per_row == 1) {
if ($post_counter > 1) {
echo "</div><!-- End of post_row -->\n"; // End previous row
}
echo "<div class='post_row'>\n"; // Start a new row
}
echo "<div class='post_class'>\n"; // Start one post
// Output post data here
echo '<h2>';the_title();echo '</h2>';
the_excerpt();
echo "</div><!-- End of post_class -->\n"; // End of post
} ?>
</div><!-- End of post_row -->
<div class='clear'></div>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php } else {
// Code for no posts found
}
?>
&#13;
但是,结果只是标题和帖子摘要,我如何用永久链接作为链接制作帖子标题,就像这段代码
<h2><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
&#13;
我想,我应该编辑
echo '<h2>';the_title();echo '</h2>';
&#13;
答案 0 :(得分:2)
非常简单
echo '<h2>'.get_the_title($post->ID).'</h2>'; // For title
echo '<a href="'.get_permalink($post->ID).'">'.get_the_title($post->ID).'</a>';
答案 1 :(得分:0)
<h2><a href="<?php echo the_permalink() ?>" title="<?php echo the_title(); ?>"><?php echo the_title(); ?></a></h2>
您应该使用<?php echo the_title(); ?>
或<?= the_title(); ?>