وردپرس

Block theme template for a custom post type


Hello,

I have a site that used to have a classic theme and a custom post type (registered with my own plugin). The type has some custom fields, and it appears in the admin panel, where I can easily add new posts. For the classic theme, I made a .php file to display the custom post type.

Recently, I decided to switch to a block theme (Twenty Twenty-Three). It doesn’t use php files, but html templates. I wanted to use this guide to make the custom post template, but my custom post type doesn’t appear under the “+” button for adding new templates. ?

Almost all the online guides for custom post types are about classic themes, not block themes, so I can’t really find any information about what’s wrong. Could there be something missing in the function for registering new post type? Here’s what it looks like now:

register_post_type('my_custom_post',
  array(
    'labels' => array(
      'name' => __('My custom posts', 'textdomain'),
      'singular_name' => __('Custom post', 'textdomain'),
    ),
    'public' => true,
    'publicly_queryable' => true,
    'has_archive' => true,
    'rewrite' => array( 'slug' => 'mypost' ),
    'supports' => array( 'title' ),
  )
);

این خبر را در ایران وب سازان مرجع وب و فناوری دنبال کنید

مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد

منبع: انجمن وردپرس

دکمه بازگشت به بالا