本文整理汇总了PHP中wp_paginate函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_paginate函数的具体用法?PHP wp_paginate怎么用?PHP wp_paginate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_paginate函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shortcode_testimonials
function shortcode_testimonials($atts)
{
$args = array('posts_per_page' => isset($atts['per_page']) ? $atts['per_page'] : 2, 'paged' => get_query_var('paged'), 'order' => isset($atts['order']) ? $atts['order'] : 'DESC', 'orderby' => isset($atts['orderby']) ? $atts['orderby'] : 'date', 'post_type' => 'testimonial');
$output = '';
if (isset($atts['category'])) {
$ids = explode(',', $atts['category']);
$slugs = array();
foreach ($ids as $id) {
if ($term = get_term_by('id', $id, 'testimonial_category')) {
$slugs[] = $term->slug;
}
}
$args['testimonial_category'] = implode(',', $slugs);
}
if (query_posts($args)) {
if (have_posts()) {
ob_start();
echo '<div class="testimonial-category">';
while (have_posts()) {
the_post();
$testimonial = new WP_Testimonial(get_the_ID());
$testimonial->word_limit = isset($atts['word_limit']) && is_numeric($atts['word_limit']) ? $atts['word_limit'] : -1;
$testimonial->render();
}
$pagination = true;
if (isset($atts['pagination']) && $atts['pagination'] == 'false') {
$pagination = false;
}
if ($pagination) {
if (function_exists('wp_paginate')) {
wp_paginate();
} else {
global $wp_query;
$big = 9999999;
echo paginate_links(array('base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), 'format' => '?paged=%#%', 'current' => max(1, get_query_var('paged')), 'total' => $wp_query->max_num_pages));
}
}
echo '</div>';
$output = ob_get_contents();
ob_end_clean();
}
wp_reset_query();
return $output;
}
}
示例2: get_template_part
get_template_part('templates/post-blog-format2');
break;
case 'classic':
default:
get_template_part('templates/post-blog-classic');
break;
}
}
?>
</ul>
</div>
<div class="pagination_wrap clearfix">
<?php
wp_paginate();
?>
<?php
wp_paginate_dropdown();
?>
</div>
</div>
<?php
get_sidebar();
?>
示例3: weaverii_content_nav
/**
* Display navigation to next/previous pages when applicable
*/
function weaverii_content_nav($nav_id, $from_search = false)
{
global $wp_query;
if ($wp_query->max_num_pages > 1) {
?>
<nav id="<?php
echo $nav_id;
?>
">
<h3 class="assistive-text"><?php
echo __('Post navigation', 'weaver-ii');
?>
</h3>
<?php
if (weaverii_getopt('wii_nav_style') == 'prev_next') {
?>
<div class="nav-previous"><?php
next_posts_link('<span class="meta-nav">← </span>' . __('Previous Post', 'weaver-ii'));
?>
</div>
<div class="nav-next"><?php
previous_posts_link(__('Next Post', 'weaver-ii') . '<span class="meta-nav">→ </span>');
?>
</div>
<?php
} else {
if (weaverii_getopt('wii_nav_style') == 'paged_left') {
echo "\t<div class=\"nav-previous\">";
if (function_exists('wp_pagenavi')) {
wp_pagenavi();
} else {
if (function_exists('wp_paginate')) {
wp_paginate('title=');
} else {
echo weaverii_get_paginate_archive_page_links('plain', 2, 3);
}
}
echo "\t</div>\n";
} else {
if (weaverii_getopt('wii_nav_style') == 'paged_right') {
echo "\t<div class=\"nav-next\">";
if (function_exists('wp_pagenavi')) {
wp_pagenavi();
} else {
if (function_exists('wp_paginate')) {
wp_paginate('title=');
} else {
echo weaverii_get_paginate_archive_page_links('plain', 2, 3);
}
}
echo "\t</div>\n";
} else {
// Older/Newer posts
?>
<div class="nav-previous"><?php
next_posts_link(__('<span class="meta-nav">←</span> Older posts', 'weaver-ii'));
?>
</div>
<div class="nav-next"><?php
previous_posts_link(__('Newer posts <span class="meta-nav">→</span>', 'weaver-ii'));
?>
</div>
<?php
}
}
}
?>
</nav><div class="weaver-clear"></div><!-- #<?php
echo $nav_id;
?>
-->
<?php
}
}
示例4: do_shortcode
if (($h1 = weaverii_getopt('wii_info_html2')) != '') {
echo '<span id="infobar_html2">';
echo do_shortcode($h1);
echo "</span>\n";
}
?>
<span class='infobar_right'>
<?php
if (!weaverii_getopt_checked('wii_info_hide_pagenav')) {
echo '<span id="infobar_paginate">';
if (!is_singular()) {
if (function_exists('wp_pagenavi')) {
wp_pagenavi();
} else {
if (function_exists('wp_paginate')) {
wp_paginate('title=');
} else {
echo weaverii_get_paginate_archive_page_links('plain', 2, 2);
}
}
}
echo "</span>\n";
}
if (weaverii_getopt('wii_info_search')) {
if (function_exists('weaverii_plus_search_form')) {
echo '<span id="infobar_search" style="padding-right:4px !important;display:inline-block;padding-left:20px;">';
echo weaverii_plus_search_form('', 120);
echo '</span>';
} else {
echo '<span id="infobar_search">';
get_search_form();
示例5: navigate_archives
function navigate_archives($bool)
{
if (function_exists('wp_paginate')) {
wp_paginate();
$bool = true;
}
return $bool;
}
示例6: the_permalink
echo the_permalink();
?>
" class="read-more">Read more ...</a>
<!-- .entry-meta -->
</article><!-- #post -->
</div>
</div>
<?php
}
?>
<?php
if (function_exists('wp_paginate')) {
wp_paginate('range=4&anchor=2&nextpage=Next&previouspage=Previous');
}
?>
<?php
} else {
?>
<div id="post-404" class="noposts">
<p><?php
_e('None found.', 'example');
?>
</p>
</div><!-- /#post-404 -->
示例7: wallow_navigate_archives
function wallow_navigate_archives()
{
global $paged;
if (!is_archive() && !is_search() && !is_home()) {
return;
}
if (!$paged) {
$paged = 1;
}
$output = '';
$output .= get_next_posts_link() ? get_next_posts_link('« ' . __('Older Posts', 'wallow')) : '';
$output .= get_next_posts_link() && get_previous_posts_link() ? ' | ' : '';
$output .= get_previous_posts_link() ? get_previous_posts_link(__('Newer Posts', 'wallow') . ' »') : '';
?>
<div class="nav_pages archive-navigation numeric-nav navigation-links">
<?php
if (function_exists('wp_pagenavi')) {
?>
<?php
wp_pagenavi();
?>
<?php
} elseif (function_exists('wp_paginate')) {
?>
<?php
wp_paginate();
?>
<?php
} else {
?>
<?php
echo $output;
?>
<?php
}
?>
</div>
<?php
}
示例8: wp_pagination
function wp_pagination($pagination_id = '', $pagination_classes = '')
{
global $wp_query;
if ($wp_query->max_num_pages > 1) {
?>
<nav id="<?php
echo $pagination_id;
?>
" class="pagination<?php
if ($pagination_classes) {
echo ' ' . $pagination_classes;
}
?>
">
<?php
if (function_exists('wp_paginate')) {
wp_paginate();
} else {
?>
<div class="pagination-prev"><?php
previous_posts_link('Anterior');
?>
</div>
<div class="pagination-next"><?php
next_posts_link('Próximo');
?>
</div>
<?php
}
?>
</nav><!-- /.pagination -->
<?php
}
}
示例9: all_category_page
function all_category_page()
{
$healthCat = get_category_by_slug('health');
$cosmeCat = get_category_by_slug('cosme');
$troubleCat = get_category_by_slug('trouble');
$componentCat = get_category_by_slug('component');
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array('paged' => $paged);
global $wp_query;
$tmp_query = $wp_query;
query_posts($args);
// fix for more tag in page
global $more;
$more = 0;
?>
<?php
if (have_posts()) {
?>
<section class="entryList">
<?php
while (have_posts()) {
the_post();
?>
<article class="entryPiece">
<a href="<?php
the_permalink();
?>
">
<header class="entryHeader">
<div class="entryInfo">
<span class="entryDate"><?php
echo get_the_date("Y/m/d");
?>
</span>
<?php
if (check_in_week(get_the_date("Y/m/d"))) {
echo '<span class="entryMark">new</span>';
}
?>
</div>
<!--//.entryInfo-->
<h1><?php
the_title();
?>
</h1>
</header>
<div class="entryOverview">
<div class="pic"> <?php
the_post_thumbnail('avatar-thumb');
?>
</div>
<div class="txt">
<?php
$category = get_the_category();
$color = "";
foreach ($category as $key => $cat) {
if ($cosmeCat->cat_ID == $cat->cat_ID || cat_is_ancestor_of($cosmeCat->cat_ID, $cat->cat_ID)) {
$color = "yellow";
} elseif ($troubleCat->cat_ID == $cat->cat_ID || cat_is_ancestor_of($troubleCat->cat_ID, $cat->cat_ID)) {
$color = "blue";
} elseif ($componentCat->cat_ID == $cat->cat_ID || cat_is_ancestor_of($componentCat->cat_ID, $cat->cat_ID)) {
$color = "purple";
}
}
?>
<div class="tagMark <?php
echo $color;
?>
"><div><span><?php
if (isset($category[0])) {
echo $category[0]->cat_name;
}
?>
</span></div></div>
<?php
the_content('', FALSE, '');
?>
<div class="viewMore"><span>続きを見る</span></div>
</div>
</div>
<!--//.entryOverview-->
</a></article>
<?php
}
?>
</section>
<?php
// Don't print empty markup if there's only one page.
if ($wp_query->max_num_pages >= 2) {
if (function_exists('wp_paginate')) {
echo '<div class="pagination">';
wp_paginate();
$current_page = isset($wp_query->query['paged']) ? $wp_query->query['paged'] : 1;
$total_items = $wp_query->found_posts;
$items_per_page = $wp_query->query_vars['posts_per_page'];
$from = ($current_page - 1) * $items_per_page + 1;
$to = $current_page == $wp_query->max_num_pages ? $total_items : $current_page * $items_per_page;
//.........这里部分代码省略.........