本文整理汇总了PHP中the_posts_pagination函数的典型用法代码示例。如果您正苦于以下问题:PHP the_posts_pagination函数的具体用法?PHP the_posts_pagination怎么用?PHP the_posts_pagination使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了the_posts_pagination函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*/
function create_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$pagination_type = get_theme_mod('pagination_type', create_get_default_theme_options('pagination_type'));
/**
* Check if navigation type is Jetpack Infinite Scroll and if it is enabled, else goto default pagination
* if it's active then disable pagination
*/
if (('infinite-scroll-click' == $pagination_type || 'infinite-scroll-scroll' == $pagination_type) && class_exists('Jetpack') && Jetpack::is_module_active('infinite-scroll')) {
return false;
} elseif ('numeric' == $pagination_type && function_exists('the_posts_pagination')) {
// Previous/next page navigation.
the_posts_pagination(array('prev_text' => __('Previous page', 'create'), 'next_text' => __('Next page', 'create'), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'create') . ' </span>'));
} else {
?>
<nav class="navigation paging-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Posts navigation', 'create');
?>
</h1>
<div class="nav-links">
<?php
if (get_next_posts_link()) {
?>
<div class="nav-previous"><?php
next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'create'));
?>
</div>
<?php
}
?>
<?php
if (get_previous_posts_link()) {
?>
<div class="nav-next"><?php
previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'create'));
?>
</div>
<?php
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
}
示例2: epigone_paging_nav
/**
* ページナビゲーションを出力
*
* @return void
*/
function epigone_paging_nav()
{
$defaults = array('show_all' => false, 'prev_next' => true, 'prev_text' => __('« Previous'), 'next_text' => __('Next »'), 'end_size' => 1, 'mid_size' => 2, 'type' => 'list', 'add_args' => array(), 'add_fragment' => '', 'before_page_number' => '', 'after_page_number' => '');
echo "<div class='text-center'>";
the_posts_pagination($defaults);
echo "</div>";
}
示例3: avocation_pagination
function avocation_pagination()
{
if (is_single()) {
the_post_navigation(array('prev_text' => '<div class="avocation_previous_pagination alignleft">%title</div>', 'next_text' => '<div class="avocation_next_pagination alignright">%title</div>'));
} else {
the_posts_pagination(array('prev_text' => '<i class="fa fa-angle-double-left"></i>', 'next_text' => '<i class="fa fa-angle-double-right"></i>', 'before_page_number' => '<span class="meta-nav screen-reader-text"></span>'));
}
}
示例4: utility_pro_post_pagination
/**
* Use WordPress archive pagination.
*
* Return a paginated navigation to next/previous set of posts, when
* applicable. Includes screen reader text for better accessibility.
*
* @since 1.0.0
*
* @see the_posts_pagination()
* @return string Markup for pagination links.
*/
function utility_pro_post_pagination()
{
$args = array('mid_size' => 2, 'before_page_number' => '<span class="screen-reader-text">' . __('Page', 'utility-pro') . ' </span>');
if ('numeric' === genesis_get_option('posts_nav')) {
the_posts_pagination($args);
} else {
the_posts_navigation($args);
}
}
示例5: multishop_pagination
function multishop_pagination()
{
?>
<div class="col-md-12 multishop-default-pagination ">
<?php
if (is_single()) {
the_post_navigation(array('next_text' => '<span class="multishop_next_pagination meta-nav" aria-hidden="true">%title</span>', 'prev_text' => '<span class="multishop_previous_pagination meta-nav" aria-hidden="true">%title</span>'));
} else {
the_posts_pagination(array('prev_text' => __('<<'), 'next_text' => __('>>'), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'multishop') . ' </span>'));
}
?>
</div>
<?php
}
示例6: wimplepro_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*/
function wimplepro_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
if (ot_get_option('pagination') == 'infinite') {
wimplepro_infinite_loading('infinite');
} elseif (ot_get_option('pagination') == 'numberal') {
// Previous/next page navigation.
the_posts_pagination(array('prev_text' => __('Previous page', 'themecountry'), 'next_text' => __('Next page', 'themecountry'), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'themecountry') . ' </span>'));
} elseif (ot_get_option('pagination') == 'loading') {
wimplepro_infinite_loading();
} else {
?>
<nav class="navigation paging-navigation" role="navigation">
<span class="screen-reader-text"><?php
_e('Posts navigation', 'themecountry');
?>
</span>
<div class="nav-links">
<?php
if (get_next_posts_link()) {
?>
<div class="nav-previous"><?php
next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'themecountry'));
?>
</div>
<?php
}
?>
<?php
if (get_previous_posts_link()) {
?>
<div class="nav-next"><?php
previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'themecountry'));
?>
</div>
<?php
}
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
}
示例7: my_ajax_pagination
function my_ajax_pagination()
{
$query_vars = json_decode(stripslashes($_POST['query_vars']), true);
$query_vars['paged'] = $_POST['page'];
$posts = new WP_Query($query_vars);
$GLOBALS['wp_query'] = $posts;
add_filter('editor_max_image_size', 'my_image_size_override');
if (!$posts->have_posts()) {
get_template_part('content', 'none');
} else {
while ($posts->have_posts()) {
$posts->the_post();
get_template_part('content', get_post_format());
}
}
remove_filter('editor_max_image_size', 'my_image_size_override');
the_posts_pagination(array('prev_text' => __('Previous page', 'twentyfifteen'), 'next_text' => __('Next page', 'twentyfifteen'), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'twentyfifteen') . ' </span>'));
die;
}
示例8: photolab_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*/
function photolab_paging_nav()
{
if (function_exists('the_posts_pagination')) {
the_posts_pagination(array('prev_text' => __('← Previous', 'photolab'), 'next_text' => __('Next →', 'photolab'), 'screen_reader_text' => ''));
return;
}
global $wp_query, $wp_rewrite;
// Don't print empty markup if there's only one page.
if ($wp_query->max_num_pages < 2) {
return;
}
$paged = get_query_var('paged') ? intval(get_query_var('paged')) : 1;
$pagenum_link = html_entity_decode(get_pagenum_link());
$query_args = array();
$url_parts = explode('?', $pagenum_link);
if (isset($url_parts[1])) {
wp_parse_str($url_parts[1], $query_args);
}
$pagenum_link = remove_query_arg(array_keys($query_args), $pagenum_link);
$pagenum_link = trailingslashit($pagenum_link) . '%_%';
$format = $wp_rewrite->using_index_permalinks() && !strpos($pagenum_link, 'index.php') ? 'index.php/' : '';
$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit($wp_rewrite->pagination_base . '/%#%', 'paged') : '?paged=%#%';
// Set up paginated links.
$links = paginate_links(array('base' => $pagenum_link, 'format' => $format, 'total' => $wp_query->max_num_pages, 'current' => $paged, 'mid_size' => 1, 'add_args' => array_map('urlencode', $query_args), 'prev_text' => __('← Previous', 'photolab'), 'next_text' => __('Next →', 'photolab')));
if ($links) {
?>
<nav class="navigation paging-navigation" role="navigation">
<h1 class="screen-reader-text"><?php
_e('Posts navigation', 'photolab');
?>
</h1>
<div class="pagination loop-pagination">
<?php
echo $links;
?>
</div><!-- .pagination -->
</nav><!-- .navigation -->
<?php
}
}
示例9: awesome_pagination
/**
* Customized Archive Pagination Helper function
* @since 0.1
* @return string HTML output of our pagination
*/
function awesome_pagination()
{
?>
<section class="pagination">
<?php
if (!is_single()) {
//ARCHIVE
?>
<?php
//added in 4.1, so check
if (function_exists('the_posts_pagination')) {
//numbered, pretty pagination
the_posts_pagination(array('prev_text' => '←', 'next_text' => 'Next →', 'mid_size' => 3));
} else {
previous_posts_link('← Newer Posts');
next_posts_link('Older Posts →');
}
?>
<?php
} else {
//SINGLE
?>
<?php
next_post_link('%link', '← %title');
//1 newer post
?>
<?php
previous_post_link('%link', '%title →');
//1 older post
?>
<?php
}
?>
</section>
<?php
}
示例10: simple_life_paging_nav
/**
* Display navigation to next/previous set of posts when applicable.
*/
function simple_life_paging_nav()
{
// Don't print empty markup if there's only one page.
if ($GLOBALS['wp_query']->max_num_pages < 2) {
return;
}
$pagination_type = esc_attr(simple_life_get_option('pagination_type'));
switch ($pagination_type) {
case 'numeric':
if (function_exists('wp_pagenavi')) {
wp_pagenavi();
} else {
the_posts_pagination(array('mid_size' => 2, 'prev_text' => '<span class="meta-nav"><i class="fa fa-chevron-left" aria-hidden="true"></i></span> ' . __('Previous page', 'simple-life'), 'next_text' => __('Next page', 'simple-life') . ' <span class="meta-nav"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>', 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'simple-life') . ' </span>'));
}
break;
case 'default':
the_posts_navigation(array('prev_text' => '<span class="meta-nav"><i class="fa fa-chevron-left" aria-hidden="true"></i></span> ' . __('Older posts', 'simple-life'), 'next_text' => __('Newer posts', 'simple-life') . ' <span class="meta-nav"><i class="fa fa-chevron-right" aria-hidden="true"></i></span>'));
break;
default:
break;
}
}
示例11: proper_post_navigation
function proper_post_navigation()
{
// don't bother for pages
if (!is_page()) {
//where multiple posts appear use Hybrid loop_pagination
if (!is_singular()) {
the_posts_pagination();
//otherwise, for single pages, films etc. us WP previous and next post links
} else {
?>
<nav class="navigation pagination">
<?php
previous_post_link('<span class="prev-wrapper">%link</span>');
next_post_link('<span class="next-wrapper">%link</span>');
?>
</nav>
<?php
}
?>
<?php
}
}
示例12: while
while (have_posts()) {
the_post();
?>
<?php
get_template_part('module_loop_post');
?>
<?php
}
?>
</div>
<?php
}
// extend loop()
?>
<?php
the_posts_pagination(array('mid_size' => 1, 'prev_text' => '«', 'next_text' => '»', 'type' => 'list', 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __('Page', 'lightning') . ' </span>'));
} else {
?>
<div class="well"><p><?php
_e('No posts.', 'lightning');
?>
</p></div>
<?php
}
// have_post()
?>
</main><!-- [ /.mainSection ] -->
<div class="col-md-3 col-md-offset-1 subSection">
<?php
示例13: get_template_part
<?php
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part('template-parts/content', get_post_format());
?>
<?php
}
?>
<?php
the_posts_pagination();
?>
<?php
} else {
?>
<?php
get_template_part('template-parts/content', 'none');
?>
<?php
}
?>
</main><!-- #main -->
示例14: while
/* Start the Loop */
?>
<?php
while (have_posts()) {
the_post();
?>
<?php
get_template_part('content', get_post_format());
?>
<?php
}
?>
</div>
<?php
// Previous/next post navigation.
the_posts_pagination(array('mid_size' => 2, 'prev_text' => __('Back', 'naturo_lite'), 'next_text' => __('Onward', 'naturo_lite')));
?>
<?php
} else {
?>
<?php
get_template_part('no-results', 'archive');
?>
<?php
}
?>
</section>
<?php
get_sidebar();
?>
示例15: the_title
the_title();
?>
</a></h3>
<?php
get_template_part('parts/meta');
?>
<?php
get_template_part('parts/excerpt');
?>
</article>
<?php
}
?>
<?php
} else {
?>
<h2>No posts to display</h2>
<?php
}
?>
<?php
the_posts_pagination(array('prev_text' => '← Previous', 'next_text' => 'Next →', 'before_page_number' => '<span class="meta-nav screen-reader-text">Page</span>'));
?>
<?php
get_footer();