Wordpress自定义帖子类型页面作为页面父级

时间:2014-01-13 19:23:55

标签: wordpress parent custom-post-type custom-wordpress-pages

我在使用Wordpress时遇到了问题。

我希望将自定义帖子类型页面作为父页面。

例如:

Custom Post Type :
-Custom Page 1
-Custom Page 2
-custom Page 3

Page : 
-Page 1
-Page 2
-Page 3

我希望例如将Custom Page 1作为Parent Page 1。

问题是我只是允许将一个页面作为父页面添加到另一个页面。

有人有想法吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

创建自定义页面类型 - 您必须创建name.php文件并在此处写入

<?php 
/*
Template Name: NameOfTourPageType
*/
?>

当您创建页面时,您必须将页面模板从默认值更改为右侧菜单中的NameOfTourPageType。

以下是视频帖子类型的示例,将其复制到fonctions.php。并创建single-video.php和taxonomy-video.php文件。

function create_my_taxonomies() {
       //Custom taxonomies for "Media" custom post type
   $foodTaxLabels = array(
     'name' => __('Videos taxonomies'),
     'singular_name' => __('Videos taxonomy'),
     'add_new' => _x('Add New', 'Videos taxonomy'),
     'add_new_item' => __('Add New Videos taxonomy'),
     'edit_item' => __('Edit Videos taxonomy'),
     'new_item' => __('New Videos taxonomy'),
     'all_items' => __('All Videos taxonomies'),
     'view_item' => __('View Videos taxonomy'),
     'search_items' => __('Search Videos taxonomies'),
     'not_found' =>  __('No Videos taxonomies found'),
     'not_found_in_trash' => __('No Videos taxonomies found in Trash'), 
     'parent_item_colon' => '',
     'menu_name' => __('Videos Categories')
   );
   register_taxonomy('videos-taxonomies',array('video'), array(
       'hierarchical' => true,
       'labels' => $foodTaxLabels,
       'show_ui' => true,
       'query_var' => true,
       'rewrite' => array('slug' => 'videos'),
   ));
}
add_action( 'init', 'codex_custom_init' );
add_action( 'init', 'create_my_taxonomies' );
相关问题