$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>rewrite rules - Add parent post to Custom Post Type|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

rewrite rules - Add parent post to Custom Post Type

matteradmin9PV0评论
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 6 years ago.

Improve this question

how can i add a parent post to my custom post type ?

I found an example :

function codex_custom_init() {
// Our People
$people_label = array(
    'name' => 'People',
    'singular_name' => 'People',
    'add_new' => 'Add People',
    'add_new_item' => 'Add New People',
    'edit_item' => 'Edit People',
    'new_item' => 'New People',
    'all_items' => 'All People',
    'view_item' => 'View People',
    'search_items' => 'Search People',
    'not_found' => 'No People found',
    'not_found_in_trash' => 'No People found in Trash',
    'parent_item_colon' => '',
    'menu_name' => 'People',
);
$people_args = array (
    'labels' => $people_label,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'our-people'),
    'capability_type' => 'page',
    'has_archive' => true,
    'hierarchical' => true,
    'menu_position' => null,
    'menu_icon' => get_template_directory_uri() . '/images/icons/people.png',
    'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt','page-attributes'),
);

register_post_type('people', $people_args);}
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 6 years ago.

Improve this question

how can i add a parent post to my custom post type ?

I found an example :

function codex_custom_init() {
// Our People
$people_label = array(
    'name' => 'People',
    'singular_name' => 'People',
    'add_new' => 'Add People',
    'add_new_item' => 'Add New People',
    'edit_item' => 'Edit People',
    'new_item' => 'New People',
    'all_items' => 'All People',
    'view_item' => 'View People',
    'search_items' => 'Search People',
    'not_found' => 'No People found',
    'not_found_in_trash' => 'No People found in Trash',
    'parent_item_colon' => '',
    'menu_name' => 'People',
);
$people_args = array (
    'labels' => $people_label,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true,
    'show_in_menu' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'our-people'),
    'capability_type' => 'page',
    'has_archive' => true,
    'hierarchical' => true,
    'menu_position' => null,
    'menu_icon' => get_template_directory_uri() . '/images/icons/people.png',
    'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt','page-attributes'),
);

register_post_type('people', $people_args);}
Share Improve this question asked Feb 11, 2019 at 8:20 SteveSteve 1
Add a comment  | 

1 Answer 1

Reset to default 3

Setting the hierarchical property of the post type to true let’s you set parent posts for them:

'hierarchical' => true,
Post a comment

comment list (0)

  1. No comments so far