2013-07-08 42 views
0

首先,我是WordPress的總諾貝爾,但是這個當前的項目需要wordpress,所以責任電話我必須這樣做。爲什麼我的wordpress單個自定義文章導航不起作用?

我已經創建了4個類別,每個類別都列在不同的頁面上。 類別是:

1-第2-1視頻3-幻燈片4音頻

這是我列出它自己的頁面上的每個類別: 這是READ貓。

<?php 

      $temp = $wp_query; 
      $wp_query= null; 
      $wp_query = new WP_Query(); 
      $wp_query->query('cat=8&showposts=6'.'order=DESC'.'cat=10' 
.'orderby=post_date'.'offset=0'.'&paged='.$paged); 



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

      <td class="leftBoxes "> 
      <a href="<?php the_permalink(); ?>#blog"> 
      <div class="imgMargin"> <?php the_post_thumbnail(); ?> </div></a> 
      <br> 

      <div class="boxScrollsBlogsView readFet"> 
       <a href=" <?php the_permalink(); ?>#blog" > 
      <h2><?php the_title(); ?> </h2> 
      <P class="pal"> 
      <?php the_excerpt(); ?> 
      </P> 
      </a> 
      </div> 

      </td> 

      <?php endwhile; ?> 

我用這個片段的每個分類重定向到它自己的單頁在single.php中

<?php 
$post = $wp_query->post; 
if (in_category('read')) { 
include(TEMPLATEPATH . '/singlePages/singleReadBlog.php'); 
} 
elseif (in_category('view')) { 
include(TEMPLATEPATH . '/singlePages/singleViewBlog.php'); 
} 
elseif (in_category('listen')) { 
include(TEMPLATEPATH . '/singlePages/singleListenBlog.php'); 
} 
elseif (in_category('watch')) { 
include(TEMPLATEPATH . '/singlePages/singleWatchBlog.php'); 
} 

?> 

現在這一切工作正常,但單後的網頁上接下來的文章中,一篇文章轉到其他類別,它不會停止在唯一視頻或Sildeshow或特定類別。

現在,我紅了一些建議,說我做了這一切都錯了,應該註冊爲一個函數。

誰能給個建議?

這些問題提出解決方案,爲上市的導航,但對我來說工作正常,單個職位導航某種方式搞砸了我:

Suggestion

回答

1

你可能知道,你沒有創建頁面以列出類別內容?

function get_custom_post_type_template($single_template) { 
    if (in_category('read')) { 
     $single_template = dirname(__FILE__) . '/post-type-template.php'; 
     } 
} 
return $single_template; 
} 

add_filter("single_template", "get_custom_post_type_template") ; 

看到https://codex.wordpress.org/Plugin_API/Filter_Reference/single_template

爲了您的上/下一個職位,檢查previous_post_link功能,您可以:

不管怎樣,關於你的模板,如果/ elseif的,你可能會使用single_template過濾器做到了他們限制同一類別作爲當前顯示的帖子:

previous_post_link('%link', 'Previous in category', TRUE); 

看到http://codex.wordpress.org/Function_Reference/previous_post_link

+0

你是小時候的男人! SAVED馬回來了!謝謝,說實話,這是第一次使用WP,我不知道過濾的東西......我通常在Rails和Django上工作 – 0bserver07

相關問題