替换昨天一个措辞不佳(删除)的问题。
我有一个预先建立的网站,需要Wordpress添加到它包含两个页面。
我已经完成了第一部分,并使用以下循环进行工作。
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 5,
'paged' => $paged,
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
?>
<!-- Display the Title as a link to the Post's permalink. -->
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<!-- Display the date and a link to other posts by this posts author.-->
<small><?php the_time('F jS, Y'); ?> by <?php the_author(); ?></small>
<!-- Display the Post as Excerpt. -->
<div class="blogpost">
<?php the_excerpt($more_link_text); ?>
</div>
<hr>
<?php
endwhile;
$pagetotal = $loop->max_num_pages;
if ($pagetotal > 1){
$current_page = max(1, get_query_var('paged'));
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'current' => $current_page,
'total' => $pagetotal,
'prev_text' => __('« prev'),
'next_text' => __('next »'),
));
}
}
wp_reset_postdata(); ?>上面的工作原理很好,包括分页方面,但是我现在被困在了我需要用这段代码做什么来使Permalinks显示为完整的post (目前它只是重新加载循环列表)。
我假设列表页和permalink页面都使用index.php?。
在Wordpress设置中,Permalinks设置为http://www.mywebsite.com/blog/this-is-a-post,相关的.htaccess已启动。
提前谢谢你的点灯或链接。
发布于 2018-04-12 15:09:19
当您说要显示"Permalink页面“时,您是指显示完整的博客文章,而不是列表吗?如果是这样的话,您将需要创建一个名为single.php的文件,并包含循环(最少)。
if (have_posts()) :
while (have_posts()) :
the_post();
the_content();
endwhile;
endif;您可以在这里获得更多有关创建该文件以及它如何影响内容显示的信息:
https://stackoverflow.com/questions/49797872
复制相似问题