CodeIn House

  • Laravel
  • WordPress
  • jQuery
  • Javascript
  • Contact
Home   WordPress   How to Add Custom Post Type into Existing Post Type in WordP ...

How to Add Custom Post Type into Existing Post Type in WordPress ?

July 8, 2018 by SNK

Add Custom Post Type Inside Existing Post Type in WordPress

In this tutorial we are going to see how can we add custom post types inside post type or any other custom post type you make. Its very easy and you can extend their limitless functionality.

I am going to Add “Enquiries” Section Inside My Custom Post Type” which will be “Trips”. If you want to add inside existing post type which will be “post” or “page”, just type their names and you are good to go.

Lets get started.

What are we going to do ?

  • Write Code for Custom Post Type
  • Add an action hook to enable it in your WordPress Admin Dashboard.

Add Custom Post Type in WordPress

Add New Custom Post Type Called Enquiry
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Create Custom Post Type [ Enquiries ]
function cih_create_enquiry_post_type() {
 
$labels = array(
'name' => __( 'All Enquiries' ),
'singular_name' => __( 'Enquiry' ),
'search_items' => __('All Enquiry')
);
 
$args = array(
'labels' => $labels,
'public' => true,
'capability_type' => 'post',
'rewrite' => true,
'public' => false,
'show_ui' => true,
'hirerarchial' => false,
'edit_item'           => 'Edit Enquiry',
'new_item'            => 'New Enquiry',
'view_item'           => 'View Enquiry',
'not_found'           => 'No Enquiries found.',
'not_found_in_trash'  => 'No Enquiries found in trash.',
'show_in_menu'  => 'edit.php?post_type=trips',
'supports' => array(
'title',
'excerpt',
'editor'
)
);
register_post_type( 'enquiry', $args);
 
}

Now finally call the hook that that will enable custom post type in admin dashboard.

Enable Custom Post Type
1
add_action( 'init', 'cih_create_enquiry_post_type' );

Note :- Show in Menu indicates that where you want to have your custom post type to be inside. If its removed then new menu is created in admin dashboard as “Enquiry” which will be independent and outside of other menus.

If you want to have your custom post type inside posts section then just change :

'show_in_menu' => 'edit.php?post_type=trips',

TO

'show_in_menu' => 'edit.php?post_type=posts',

OR

'show_in_menu' => 'edit.php?post_type=page',

If you have any problem regarding creating new post types let me know or feel free to comment below.

SHARE ON
Buffer

Enjoyed this article?

Like us on

WordPress how to create custom post type in wordpress without plugin wordpress custom post type tutorial

Avatar for SNK

About SNK

Hello Welcome to my Blog. I develop Websites Using Laravel Framwork & WordPress. Get Latest updates on Facebook | Twitter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Connected !! With Us

TOP POSTS

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

TUTORIALS TILL DATE

  • September 2022 (6)
  • June 2021 (7)
  • October 2020 (5)
  • September 2020 (6)
  • September 2018 (14)
  • August 2018 (3)
  • July 2018 (4)
  • March 2018 (8)
  • February 2018 (5)
  • January 2018 (1)
  • December 2017 (2)
  • August 2017 (8)
  • May 2017 (1)
  • April 2017 (1)
  • March 2017 (4)
  • February 2017 (3)
  • January 2017 (4)

CATEGORIES

  • Angular (2)
  • CSS3 (3)
  • D3 (3)
  • HTML5 (7)
  • JAVA (11)
  • Javascript (20)
  • jQuery (8)
  • Laravel (35)
  • Others (3)
  • PHP (11)
  • Spring (2)
  • WordPress (10)

Top Categories

  • Angular
  • CSS3
  • D3
  • HTML5
  • JAVA
  • Javascript
  • jQuery
  • Laravel
  • Others
  • PHP
  • Spring
  • WordPress

Get in Touch

DMCA.com Protection Status

Recent Articles

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

© 2012-22 CodeIn House.  •  All Rights Reserved.