1
votes

I create a custom hierarchical post type.

here is custom post type code:

// Register Custom Post Type
function landing_page() {

    $labels = array(
        'name'                => _x( 'Pages', 'Post Type General Name', 'download_saga' ),
        'singular_name'       => _x( 'Landing Page', 'Post Type Singular Name', 'download_saga' ),
        'menu_name'           => __( 'Landing Page', 'download_saga' ),
        'parent_item_colon'   => __( 'Parent Page:', 'download_saga' ),
        'all_items'           => __( 'All Pages', 'download_saga' ),
        'view_item'           => __( 'View Page', 'download_saga' ),
        'add_new_item'        => __( 'Add New Pages', 'download_saga' ),
        'add_new'             => __( 'New Landing Page', 'download_saga' ),
        'edit_item'           => __( 'Edit Page', 'download_saga' ),
        'update_item'         => __( 'Update Page', 'download_saga' ),
        'search_items'        => __( 'Search pages', 'download_saga' ),
        'not_found'           => __( 'No pages found', 'download_saga' ),
        'not_found_in_trash'  => __( 'No pages found in Trash', 'download_saga' ),
    );
    $rewrite = array(
        'slug'                => 'landingpage',
        'with_front'          => true,
        'pages'               => true,
        'feeds'               => true,
    );
    $args = array(
        'label'               => __( 'landingpage', 'download_saga' ),
        'description'         => __( 'Create Landing Page for Different Browser', 'download_saga' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'page-attributes' ),
        'hierarchical'        => true,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 20,
        'menu_icon'           => 'http://www.downloadsaga.com/wp-content/themes/ProjectR/images/lpage.png',
        'can_export'          => true,
        'has_archive'         => false,
        'exclude_from_search' => true,
        'publicly_queryable'  => true,
        'query_var'           => 'landingpage',
        'rewrite'             => $rewrite,
        'capability_type'     => 'page',
    );
    register_post_type( 'landingpage', $args );

}

// Hook into the 'init' action
add_action( 'init', 'landing_page', 0 );

Here is show page attributes widget when I go editor page but its not show page template lists. So, I can't select a page template for custom post page. I already create 3 page template and its works great with wordpress default page function.

Any idea what is the problem and how I solve it?

I tried it find wordpress codex, wordpress support pages, stackoverflow, ask.com .. but no where I got my correct answare :(

Help me please.

Here is screenshot of page current view

current view

2
For what it's worth, this isn't possible to do. It's hard coded in WP to only show on built-in Pages. wordpress.org/support/topic/…Elliot Lewis
@NoDiv_NoClass Exactly Same problem here! did you find any solutions?Pmpr

2 Answers

0
votes

You have solved it already, but to use a parent you need to have another item of the same type. Create an item and the next time you do it, it will show you the parent selector. Wordpress will only let you choose items of the same type as parent of another.

Hope this helps.

0
votes

Short answer, you need to create a new template with in comment to specify Template Post Type

/*
  Template Name: Full Width
  Template Post Type: post-type-name, page, projects, code
 */

You can read more in https://rainastudio.com/template-page-attributes-wordpress/