Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter mumumu

    (@imamura4108)

    Oh, I understand.
    I had made a basic misunderstanding.

    All “custom post types” in WordPress are “post types”.
    And “page type” is a special one.
    I thought I could choose one or the other.

    As you pointed out, is_page() is always false, is_single() is always true,
    and is_singular(‘contents’) which needs to be looked up in the custom name.

    Thank you for teaching me this.

    Thread Starter mumumu

    (@imamura4108)

    I’m sorry.
    I just marked it as “resolved”.

    However, I get “is_page() = false”, which is not the intended behavior.

    Is there any way to make “is_page() = true” for the post type added in the CPU UI?

    Thread Starter mumumu

    (@imamura4108)

    Thank you very much.
    I was able to apply the template.
    Thank you for your quick and accurate answer.

    Thread Starter mumumu

    (@imamura4108)

    It’s done!

    As you pointed out, I checked the “Page Attributes” checkbox in the “Supports” section of the settings page, and now it shows up.

    Thank you very much!

    Thread Starter mumumu

    (@imamura4108)

    I’ve added a whole new post type.
    The only change I made was to set “hierarchical” to “True”.

    I added two pages and set them all to “Public”.
    However, I cannot specify a parent page for either of the pages.

    Thread Starter mumumu

    (@imamura4108)

    Thank you for your reply.

    Is this the text you need?

    The only thing I’ve changed in the configuration settings.
    is probably just “hierarchy”.

    function cptui_register_my_cpts_contents() {
    
    	/**
    	 * Post Type: contents.
    	 */
    
    	$labels = [
    		"name" => __( "contents", "astra" ),
    		"singular_name" => __( "content", "astra" ),
    	];
    
    	$args = [
    		"label" => __( "contents", "astra" ),
    		"labels" => $labels,
    		"description" => "For Members",
    		"public" => true,
    		"publicly_queryable" => true,
    		"show_ui" => true,
    		"show_in_rest" => true,
    		"rest_base" => "",
    		"rest_controller_class" => "WP_REST_Posts_Controller",
    		"has_archive" => false,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"delete_with_user" => false,
    		"exclude_from_search" => true,
    		"capability_type" => "post",
    		"map_meta_cap" => true,
    		"hierarchical" => true,
    		"rewrite" => [ "slug" => "contents", "with_front" => true ],
    		"query_var" => true,
    		"supports" => [ "title", "editor", "thumbnail" ],
    		"show_in_graphql" => false,
    	];
    
    	register_post_type( "contents", $args );
    }
    
    add_action( 'init', 'cptui_register_my_cpts_contents' );
    
Viewing 6 replies - 1 through 6 (of 6 total)