我正在尝试将分页链接甚至下一页和上一页链接添加到wordpress上的静态主页,该主页使用我不熟悉的自定义循环。我有很少的php / wordpress编解码器知识,无法弄清楚如何实现这一点。下面是循环的完整代码,非常感谢任何帮助!
此外,它似乎是二十二岁的wordpress主题的儿童主题。
<?php
global $post;
//$args = array( 'numberposts' => 1, 'category' => 7 );
//$args=array( 'numberposts' => -1, 'category' => -6 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);
//echo "<pre>";
//print_r($post);
?>
<div class="post_blog">
<h1><a href="<?php the_permalink() ?>">
<?php the_title(); ?>
</a></h1>
<div class="clr"> </div>
<?php //the_date();?>
<div class="post_cont">
<div class="post_thum"> <a href="<?php the_permalink() ?>">
<?php the_post_thumbnail();?>
</a> <span class="post_slogn"><?php echo $cfs->get('post_slogen'); ?></span>
</div>
<div class="post_right">
<p>
<?php //content(120);
content(100);
//the_content("Continue reading " . the_title('', '', false));
//content('<p style="text-align: justify;"><!--more--></p>');
?>
</p>
<div class="clr"> </div>
<span class="read_entry"><a href="<?php the_permalink() ?>">MORE <span>»</span></a> </span>
<div class="share"> <span class='st_facebook' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><span class='st_twitter' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><span class='st_linkedin' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><!-- <span class='st_email' st_title='<?php //the_title(); ?>' st_url='<?php //the_permalink(); ?>'> --></span><span class='st_plusone' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span><span class='st_fblike' st_title='<?php the_title(); ?>' st_url='<?php the_permalink(); ?>'></span></div>
</div>
<div class="clr"></div>
<div class="sub_title">
<?php //the_tags(' ');
the_tags('', ' ', ' ');
?>
</div>
</div>
</div>
<?php endforeach; ?>
答案 0 :(得分:0)
如果您查看wordpress codex,您会发现需要next and previous posts links.
<?php next_post_link('%link', 'Name of your next post link', TRUE); ?>
<?php previous_post_link('%link', 'Name of your previous post link', TRUE); ?>
此外,您应read this exchange了解如何在wordpress循环中实现分页。