2014-12-04 139 views
0

我正在wordpress網站上工作。我需要添加自定義的Post類型。我創建了一個自定義帖子類型products,其分類標準爲product_type,與category類似。 product_type有各種分類標準值。其中一些是flowersextracts等。WordPress的自定義帖子類型模板

現在我正試圖訪問此鏈接http://farma.mechadigital.net/products/product_type/flowers/它不適合我。

我已添加一些文件。

archive-products => This should be the custom post template 
taxonomy-product_type.php => This should be the taxonomy Template 
taxonomy-product_type-flowers.php => This should be the template for the term value flowers 

這裏是我已經包含在functions.php中的代碼。我不知道我在哪裏做錯了。

的functions.php

function farma_products() { 
     $labels = array(
      // List of arguments 
     ); 

     $args = array(
      // list of arguments 
      'rewrite'   => array('slug' => 'products'), 
     ); 


     register_post_type('products', $args); 
     flush_rewrite_rules(false); 
    } 

    add_action('init', 'farma_products_type'); 

    function farma_products_type() { 
     register_taxonomy(
      'product_type', 
      'products', 
      array(
       'label' => __('Product Type'), 
       'rewrite' => array('slug' => 'products/product_type'), 
       'hierarchical' => true, 
      ) 
     ); 
    } 
+0

有你在去您的管理員設置,然後點擊 「保存」 重新保存您的永久鏈接? – rnevius 2014-12-04 08:54:20

+0

嘗試刪除重寫,將您的固定鏈接重置爲默認值,然後從類別 - >視圖中訪問頁面。這應該給你一個想法,如果它的工作。 – nunorbatista 2014-12-04 11:39:59

回答

0
Put this function in your functions.php  

//start function 
add_action('init', 'farma_products'); 
    function farma_products() { 
      $labels = array(
       // List of arguments 
      ); 

      $args = array(
       // list of arguments 
       'rewrite'   => true,   
      ); 

    //register your custom post type 
      register_post_type('products', $args); 
      add_rewrite_rule('products/page/([0-9]+)/?$', 'index.php?pagename=products&paged=$matches[1]', 'top'); 
     } 

//end function 
相關問題