WordPress   

Add new custom post without plugin in WordPress

Below given code snippet is customized for creating PDF files post. You can easily change the values in this code snippet to customize it according to your requirements. After customizing this code snippet, just paste it in the functions.php file of active theme and you are done.

 function create_custom_post_pdf() {
  $labels = array(
    'name'               => esc_html__( 'PDF Files', 'text-domain' ),
    'singular_name'      => esc_html__( 'PDF File', 'text-domain' ),
    'add_new'            => esc_html__( 'Add New', 'text-domain' ),
    'add_new_item'       => esc_html__( 'Add New PDF File', 'text-domain' ),
    'edit_item'          => esc_html__( 'Edit PDF File', 'text-domain' ),
    'new_item'           => esc_html__( 'New PDF File', 'text-domain' ),
    'all_items'          => esc_html__( 'All PDF Files', 'text-domain' ),
    'view_item'          => esc_html__( 'View PDF File', 'text-domain' ),
    'search_items'       => esc_html__( 'Search PDF Files', 'text-domain' ),
    'not_found'          => esc_html__( 'No PDF Files found', 'text-domain' ),
    'not_found_in_trash' => esc_html__( 'No PDF Files found in the Trash', 'text-domain' ), 
    'parent_item_colon'  => '',
    'menu_name'          => ' PDF Files'
  );
  $args = array(
    'labels'        => $labels,
    'description'   => 'Custom post for storing PDF files',
    'public'        => true,
    'publicly_queryable' => true,
    'menu_position' => 5,
    'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
    'exclude_from_search' => false,
    'has_archive'   => true,
    'menu_icon'     => 'dashicons-carrot',
    'rewrite'       => array('slug' => 'pdf-file'),
  );
  register_post_type( 'pdf-files', $args ); 
}
add_action( 'init', 'create_custom_post_pdf' );
Need Professional Support for Your Website Problems?

Whether you're facing website issues or struggling with code implementation, our team is here to assist. Hire us to get your website back on track.

Hire Us

Got an idea? We'll turn it into reality.

Tell us what you're building, what's broken, or what numbers need to move. We'll come back within one business day with a short plan — no long decks, no sales calls without purpose.

Response time: First reply within 1 business day on 100% of messages.
Transparent scope: Fixed proposals with weekly check-ins & live task tracking.
Ship-ready builds: Every engagement leaves behind documented, transferable work.
Long-term partners: Ongoing retainers for support, SEO, ads, and content.