我正在使用提供的一些代码in an answer 在此处计算“post X of Y”并在single上显示分页图标。php。
它工作得很好,但会导致显示问题the_content();
在我的本地MAMP服务器上,它在每篇文章中显示第一篇文章的内容,而在我的web服务器上,它根本不显示内容。
我的完整代码如下:
<div class="project-pagination">
<?php
// save current id to match later
$current_project_id = $post->ID;
$args = array(
\'post_type\' => \'portfolio\',
\'posts_per_page\' => -1
);
$all_projects = new WP_Query( $args );
?>
<ul>
<?php
while( $all_projects->have_posts() ) : $all_projects->the_post();
// simple \'if\' test to find the current post in the loop
// note that current_post starts at zero, which is why we add 1 to it.
// you can also output the_title, the_permalink, thumbnails, etc..
$permalink = get_permalink();
$projectnum = $all_projects->current_post+1;
if( $post->ID == $current_project_id ){
echo "<li class=\'project-page-btn-current\'></li>";
}else {
echo "<li><a class=\'project-page-btn\' href=\'".$permalink."\'></a></li>";
}
endwhile;
?>
</ul>
</div>
任何帮助都将不胜感激!
非常感谢。