2016-07-29 35 views
1

Ich habe benutzerdefinierte Post-Typ "Verzeichnis" erstellt und benutzerdefinierte Taxonomie "Verzeichnis-Kategorie" registriert. Es ist jedoch nicht möglich, auf die Taxonomieseite "taxonomy-directory-category.php" zuzugreifen. Der Fehler "Fehler 404 - Nicht gefunden" wird angezeigt.Benutzerdefinierte Taxonomie-Seite funktioniert nicht

function create_post_type_listing() { 
register_post_type('directory', 
    array(
     'labels' => array(
      'name' => __('Listings'), 
        'singular_name' => __('Listing'), 
      'add_new' => __('Add New Listing'), 
      'add_new_item' => __('Add New Listing'), 
      'edit' => __('Edit Listing'), 
       'edit_item' => __('Edit Listing'), 
       'new_item' => __('New listing'), 
       'view' => __('View Listing'), 
       'view_item' => __('View Listing'), 
       'search_items' => __('Search Listings'), 
       'not_found' => __('No listings found'), 
       'not_found_in_trash' => __('No listings found in Trash'), 
       'featured_image' => __('Listing Image'), 
       'set_featured_image' => __('Set Listing Image'), 
       'remove_featured_image' => __('Remove Listing Image'), 
       'use_featured_image' => __('Use Listing Image') 
        ), 
    'public' => true, 
    'menu_position' => 5, 
    'menu_icon' => plugins_url('images/listing-20x20.png', __FILE__), 
    'rewrite' => array(
     'slug' => __('directory') 
    ), 
    'supports' => array('title','editor','thumbnail'))); 
} 

add_action('init', 'create_listing_taxonomies', 0); 
function create_listing_taxonomies() { 
// Add new taxonomy, make it hierarchical (like categories) 
$labels = array(
    'name'    => 'Listing Categories', 
    'singular_name'  => 'Listing Category', 
    'search_items'  => 'Listing Categories', 
    'all_items'   => 'All Listing Categories', 
    'parent_item'  => 'Parent Listing Category', 
    'parent_item_colon' => 'Parent Listing Category:', 
    'edit_item'   => 'Edit Listing Category', 
    'update_item'  => 'Update Listing Category', 
    'add_new_item'  => 'Add New Listing Category', 
    'new_item_name'  => 'New Listing Category', 
    'menu_name'   => 'Listing Category', 
); 

$args = array(
    'hierarchical'  => true, 
    'labels'   => $labels, 
    'show_ui'   => true, 
    'show_admin_column' => true, 
    'query_var'   => true, 
    'rewrite'   => array('slug' => 'directory-category'), 
); 

register_taxonomy('directory-category', array('directory'), $args); 
} 

function listing_flush_rules() { 
//defines the post type so the rules can be flushed. 
create_post_type_listing(); 

//and flush the rules. 
flush_rewrite_rules(); 
} 
register_activation_hook(__FILE__, 'listing_flush_rules'); 
add_action('init', 'create_post_type_listing'); 

Bitte helfen Sie mir mit Taxonomie Seitenstruktur.

Grüße, Shubhajeet Saha

Antwort

-1

Bitte unten Code in Ihre functions.php hinzuzufügen oder in Ihrem Plugin-Seite

add_action('init', 'create_taxonomies', 0); 

function create_taxonomies() { 
      //change start/// 
      $title = 'Your title'; 
      $slug = 'yourslug'; 
      $your_plugin_textdomain = 'textdomain'; 
      //change end/// 

      $labels = array(
       'name' => _x($title, $your_plugin_textdomain), 
       'singular_name' => _x($title, $your_plugin_textdomain), 
       'search_items' => __('Search Genres'), 
       'all_items' => __('All ' . $title), 
       'parent_item' => __('Parent ' . $title), 
       'parent_item_colon' => __('Parent ' . $title . ':'), 
       'edit_item' => __('Edit ' . $title), 
       'update_item' => __('Update ' . $title), 
       'add_new_item' => __('Add New ' . $title), 
       'new_item_name' => __('New ' . $title . ' Name'), 
       'menu_name' => __(ucfirst($title)), 
      ); 

      $args = array(
       'hierarchical' => true, 
       'labels' => ($labels), 
       'show_ui' => true, 
       // 'show_admin_column' => true, // to display taxonomy in post table 
       'query_var' => true, 
       'rewrite' => array('slug' => $slug), 
      ); 
      register_taxonomy($slug, array($catname[$key]), $args); 

} 
+0

groß, dass u Problem bekommen haben. – Shafi