Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the astra domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/sqrtyhjzaqx471/public_html/wp-includes/functions.php on line 6121

Home Forums WordPress created a custom plugin but custom post type is not appearing in admin panel on Reply To: created a custom plugin but custom post type is not appearing in admin panel on

#139
avi
Participant
<?php
/*
Plugin Name: Custom Post Types
Description: Add post types for custom articles
Author: Hostinger Dev
*/
// Hook ht_custom_post_custom_article() to the init action hook
add_action( 'init', 'custom_post' );
// The custom function to register a custom article post type
function custom_post() {
// Set the labels. This variable is used in the $args array
$labels = array(
'name' => __( 'Custom Articles' ),
'singular_name' => __( 'Custom Article' ),
'add_new' => __( 'Add New Custom Article' ),
'add_new_item' => __( 'Add New Custom Article' ),
'edit_item' => __( 'Edit Custom Article' ),
'new_item' => __( 'New Custom Article' ),
'all_items' => __( 'All Custom Articles' ),
'view_item' => __( 'View Custom Article' ),
'search_items' => __( 'Search Custom Article' ),
'featured_image' => 'Poster',
'set_featured_image' => 'Add Poster'
);
// The arguments for our post type, to be entered as parameter 2 of register_post_type()
$args = array(
'labels' => $labels,
'description' => 'Holds our custom article post specific data',
'public' => true,
'menu_position' => 6,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields' ),
'has_archive' => true,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'query_var' => true,
);
// Call the actual WordPress function
// Parameter 1 is a name for the post type
// Parameter 2 is the $args array
register_post_type('article', $args);
}

This may help…!

Scroll to Top