0
我正在使用Wordpress的骨骼主題。Wordpress分頁與第一頁上的特色帖子的添加分開
我有一個博客頁面,在3x3佈局中,每頁之後有9篇文章,第3頁上方有一個大(最近的)文章的第一頁除外。分頁工作正常,直到帖子等於9 + 1的倍數,所以像19,28,37 ...
我意識到,在第一頁上放置較大的特色帖子必須打破它,我只是無法弄清楚如何改變它。
這是導航是如何叫bones.php
function bones_page_navi($before = '', $after = '') {
global $wpdb, $wp_query;
$request = $wp_query->request;
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;
$max_page = $wp_query->max_num_pages;
if ($numposts <= $posts_per_page) { return; }
if(empty($paged) || $paged == 0) {
$paged = 1;
}
$pages_to_show = 7;
$pages_to_show_minus_1 = $pages_to_show-1;
$half_page_start = floor($pages_to_show_minus_1/2);
$half_page_end = ceil($pages_to_show_minus_1/2);
$start_page = $paged - $half_page_start;
if($start_page <= 0) {
$start_page = 1;
}
$end_page = $paged + $half_page_end;
if(($end_page - $start_page) != $pages_to_show_minus_1) {
$end_page = $start_page + $pages_to_show_minus_1;
}
if($end_page > $max_page) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if($start_page <= 0) {
$start_page = 1;
}
echo $before.'<nav class="page-navigation"><ol class="bones_page_navi clearfix">'."";
if ($start_page >= 2 && $pages_to_show < $max_page) {
$first_page_text = "First";
echo '<li class="bpn-first-page-link"><a href="'.get_pagenum_link().'" title="'.$first_page_text.'">'.$first_page_text.'</a></li>';
}
echo '<li class="bpn-prev-link">';
previous_posts_link('«');
echo '</li>';
for($i = $start_page; $i <= $end_page; $i++) {
if($i == $paged) {
echo '<li class="bpn-current">'.$i.'</li>';
} else {
echo '<li><a href="'.get_pagenum_link($i).'">'.$i.'</a></li> <!--'.$paged.' is paged and '.$end_page.' is end page. '.$numposts.' is numposts '.$max_page.' is maxpage'.$posts_per_page.'-->'; // **ISSUE LIES HERE WITH TOO MANY PAGES
}
}
echo '<li class="bpn-next-link">';
next_posts_link('»');
echo '</li>';
if ($end_page < $max_page) {
$last_page_text = "Last";
echo '<li class="bpn-last-page-link"><a href="'.get_pagenum_link($max_page).'" title="'.$last_page_text.'">'.$last_page_text.'</a></li>';
}
echo '<a href="'.home_url().'/about#users" class="browse mobile-hide">Browse authors</a></ol></nav>'.$after."";
}
這就是我如何把最近的帖子我的索引頁上。
<?php if (have_posts()) : ?>
<?php $post = $posts[0]; $c=0;?>
<?php while (have_posts()) : the_post(); ?>
<?php $c++;
if(!$paged && $c == 1) : // code for the first post ?>
<div><article id="post-<?php the_ID(); ?>" <?php post_class('clearfix blog first-blog'); ?> role="article">
<header class="article-header">
<?php if (has_post_format('link')) { ?>
<a href="<?php echo get_post_meta($post->ID, 'link_url', true); ?>" rel="bookmark" title="Visit link: <?php the_title_attribute(); ?>" target="_blank">
<?php } else { ?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<?php }; ?>
<div class="date">
<time class="updated" datetime="<?php echo the_time('Y-m-j'); ?>" pubdate>
<span class="month"><?php the_time('M'); ?></span>
<span class="day"><?php the_time('j'); ?></span>
<span class="year"><?php the_time('Y'); ?></span>
</time>
</div>
<?php if (has_post_format('link')) {
echo '<div class="link"><i class="icon-link"></i></div>';
} ?>
<h1 class="h2"><?php the_title(); ?></h1>
</a>
</header> <!-- end article header -->
<?php if (has_post_format('link')) {
echo '';
} else { ?>
<div class="blog-body clearfix">
<?php if (has_post_format('video')) {
echo '<div class="eightcol first vid">'.get_post_meta($post->ID, 'video_url', true).'</div>';
} else { ?>
<a class="image mobile-hide" href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail('large', array('class' => 'mobile-hide eightcol first')); ?>
</a>
<?php } ?>
<section class="entry-content clearfix mobile-hide fourcol last">
<p class="byline"><?php _e('by', 'bonestheme'); ?> <span class="author"><?php the_author_posts_link(); ?></span></p>
<?php the_content('Continue reading...'); ?>
</section> <!-- end article section -->
</div><!-- end blog body -->
<?php } ?>
</article></div> <!-- end article -->
對不起,我還是PHP的新手。