2016-01-06 113 views
1
WordPress的頁面上

我犯了一個頁面,顯示職位,但分頁不出現(1,2,3等)分頁不工作

這是代碼:

<div class="browse-content"> 
    <div class="container"> 
     <h2><?php echo wp_count_posts()->publish; ?> Movies Found</h2> 
     <section> 
      <div class="row"> 
       <ul>  
       <?php 
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
        $args = array(
         'posts_per_page' => 3, 
         'paged'   => $paged 
        ); 

        $the_query = new WP_Query($args); 
       ?> 
        <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> 
         <?php include '_includes/items/item_2.php';?> 
       <?php endwhile; wp_reset_postdata();?> 
       </ul> 
      </div> 
     </section> 
     <div class="pagination"><?php novavideo_theme_pagination(); ?></div><!-- .pagination --> 
     </div> 
    </div> 
</div>  

我搜索了無處不在,但我沒有找到答案...

有人可以幫助我嗎?

+0

你可以檢查當前的'發佈ID <分頁* posts_per_page'和'發佈ID =>分頁* posts_per_page'。 – DaMaGeX

+0

請分享您用於此功能的代碼:novavideo_theme_pagination(); –

回答

-1
 <?php 
$args = array('posts_per_page' => 20); 
$the_query = new WP_Query($args);?> 
<?php if ($the_query->have_posts()) : ?> 
    <?php while ($the_query->have_posts()) : $the_query->the_post(); ?> 
    <li> 
    <h4><a class="text_aktualnosci" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 
     <span class="data_dodania_arch"><?php _e('Data dodania: '); ?><strong><?php echo get_the_date(); ?></strong></span> 
    </h4> 
    </li> 
    <?php endwhile; ?><!-- end of the loop --> 
    <!-- put pagination functions here --> 
<?php else: ?> 
<p></p> 
<?php endif; ?> 
+0

Doesn; t works .. –

0
function novavideo_theme_pagination($pages = '', $range = 4){ 
$showitems = ($range * 2)+1; 

global $paged; 
if(empty($paged)) $paged = 1; 

if($pages == '') 
{ 
    global $wp_query; 
    $pages = $wp_query->max_num_pages; 
    if(!$pages) 
    { 
     $pages = 1; 
    } 
} 

if(1 != $pages) 
{ 
    echo "<div class=\"pagination\"><ul><li><span>Page ".$paged." of ".$pages."</span></li>"; 

    if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link(1)."'>&laquo; First</a></li>"; 
    if($paged > 1 && $showitems < $pages) echo "<li><a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a></li>"; 

    for ($i=1; $i <= $pages; $i++) 
    { 
     if (1 != $pages &&(!($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems)) 
     { 
      echo ($paged == $i)? "<li><span class=\"current\">".$i."</span></li>":"<li><a href='".get_pagenum_link($i)."' class=\"inactive\">".$i."</a></li>"; 
     } 
    } 

    if ($paged < $pages && $showitems < $pages) echo "<li><a href=\"".get_pagenum_link($paged + 1)."\">Next &rsaquo;</a></li>"; 
    if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<li><a href='".get_pagenum_link($pages)."'>Last &raquo;</a></li>"; 
    echo "</ul></div>\n"; 
} 

}

這是代碼

+0

PS:對於其他頁面的導航工作.. –

0

添加這兩條線到你的主題function.php文件,一切都將得到回去工作:

add_filter(‘redirect_canonical’,’custom_disable_redirect_canonical’); 

function custom_disable_redirect_canonical($redirect_url) {if (is_paged() && is_singular()) $redirect_url = false; return $redirect_url; }