Custom Post Types in WordPress refer to a feature that allows users to define and create content types beyond the default ones, such as posts and pages. Essentially, it enables you to introduce new content structures tailored to your website’s specific needs.
For instance, if your website focuses on a portfolio, testimonials, events, or any other unique content, you can create a custom post type for each of these. This helps organize and manage content more efficiently, providing a dedicated structure for different types of information.
In this blog post, I’ll guide you through creating and managing custom post types in WordPress
<?php
add_action( 'init', 'create_partners', 0 );
function create_partners() {
$singular = esc_html__('wpdumi Partner', 'wpdumi-partners');
$plural = esc_html__('wpdumi Partners', 'wpdumi-partners');
$labels = array(
'name' => $plural,
'singular_name' => $singular,
'menu_name' => sprintf(esc_html__('%s', 'wpdumi-partners'), $plural),
'all_items' => sprintf(esc_html__('All %s', 'wpdumi-partners'), $plural),
'add_new' => esc_html__( 'Add New', 'wpdumi-partners' ),
'add_new_item' => sprintf( esc_html__('Add %s', 'wpdumi-partners'), $singular ),
'edit' => esc_html__( 'Edit', 'wpdumi-partners' ),
'edit_item' => sprintf( esc_html__( 'Edit %s', 'wpdumi-partners' ), $singular ),
'new_item' => sprintf( esc_html__( 'New %s', 'wpdumi-partners' ), $singular ),
'view' => sprintf( esc_html__( 'View %s', 'wpdumi-partners' ), $singular ),
'view_item' => sprintf( esc_html__( 'View %s', 'wpdumi-partners' ), $singular ),
'search_items' => sprintf( esc_html__( 'Search %s', 'wpdumi-partners' ), $plural ),
'not_found' => sprintf( esc_html__( 'No %s found', 'wpdumi-partners' ), $singular ),
'not_found_in_trash' => sprintf( esc_html__( 'No %s found in trash', 'wpdumi-partners' ), $plural ),
'parent' => sprintf( esc_html__( 'Parent %s', 'wpdumi-partners' ), $singular )
);
// Set other arguments for the partners post type.
$args = array(
'label' => __( 'Partner', 'wpdumi-partners' ),
'description' => __( 'Partners.', 'wpdumi-partners' ),
'labels' => $labels,
'supports' => array(
'title',
'editor',
'excerpt',
'author',
'thumbnail',
'comments',
'revisions',
'custom-fields',
),
'taxonomies' => array(),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
// Registes the wpdumi-partners post type.
register_post_type( 'partner', $args );
}
?>
Reference
An all round web designer building websites Over 18 years. Interested in achieving a suitable placement in the field of IT in a growth oriented organization which offers diverse job responsibilities in order to utilize and improve my skills, Knowledge and experience.