2013-04-01 69 views
0

我實現了一個自定義後類型的唱片分頁。 我設法編輯我的模板的循環,因此它顯示所有與「軌道」類型的帖子,但現在分頁不再工作。試圖執行一個特定類別(WordPress的)

這是循環的代碼:

<?php 
$args = array('post_type' => 'Track', 'posts_per_page' => 5); 
    $loop = new WP_Query($args); 

while ($loop->have_posts()) : $loop->the_post(); 
?> 

//HERE COMES MY HTML STUFF 


<?php endwhile;?> 
<?php fuse_pagenavi(); ?> 

這是代碼爲我fuse_pagenavi():

<?php 
function fuse_pagenavi($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\"><span class=\"pageof\">Page ".$paged." of ".$pages."</span>"; 
     if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>&laquo; First</a>"; 
     if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>&lsaquo; Previous</a>"; 

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

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

預先感謝您!

更新:

好的我想我會取得一些進展。 我安裝了wp-pagenavi插件,現在我在頁面底部看到分頁鏈接,但它們指向mysite.com/?paged=x而不是指向mysite.com/?page=x ....我與「頁面」手動測試,它的工作原理...

的代碼如下:

<?php 
$paged = get_query_var('page'); 
$my_query = new WP_Query($args); 

$args = array('post_type' => 'Track', 'posts_per_page' => 5,'paged' => $paged); 
     $loop = new WP_Query($args); 
while ($loop->have_posts()) : $loop->the_post(); 
?> 

//HTML STUFF 


<?php 
wp_pagenavi(array('query' => $loop)); 
wp_reset_postdata(); 
?> 

我怎樣才能讓我的分頁鏈接指向而不是mysite.com?page=x的分頁= X。 謝謝

回答

1

試試這個:

<?php 
if (get_query_var('paged')) { $paged = get_query_var('paged'); } 
elseif (get_query_var('page')) { $paged = get_query_var('page'); } 
else { $paged = 1; } 
$args = array('post_type' => 'Track', 'posts_per_page' => 5, 'paged' => $paged); 
    $loop = new WP_Query($args); 

while ($loop->have_posts()) : $loop->the_post(); 
?> 

//HERE COMES MY HTML STUFF 


<?php endwhile;?> 
<?php fuse_pagenavi(); ?> 
+0

不工作:((( –

相關問題