Custom post type
Today we are going to discuss to create custom post type in WordPress. As you know over the past years, WordPress has evolved into a powerful content management system and user-friendly.
WordPress custom post types enable you to create customized content for any type of website. Learn what they are good for and how to set them up now.
The custom post type feature is what transforms WordPress from a blogging platform to a fully-fledged content management system.
If you installed WordPress(Follow the steps to install WORDPRESS in your Local Server), you will see that default post and pages inside the WordPress.
However you can create as many custom content types as you like, and these custom content types are referred to as Custom Post Types if you want to create user custom system.
Here we are creating a new post type with name food.
Create post type.
//Custom Post type add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'food', array( 'labels' => array( 'name' => __( 'Food' ), 'singular_name' => __( 'Food' ) ), 'public' => true, 'has_archive' => true, 'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ), ) ); }
Then register the taxonomies
function create_vacatures_taxonomies() { $labels = array( 'name' => _x( 'Categories', 'taxonomy general name' ), 'singular_name' => _x( 'Category', 'taxonomy singular name' ), 'search_items' => __( 'Search Categories' ), 'all_items' => __( 'All Categories' ), 'parent_item' => __( 'Parent Category' ), 'parent_item_colon' => __( 'Parent Category:' ), 'edit_item' => __( 'Edit Category' ), 'update_item' => __( 'Update Category' ), 'add_new_item' => __( 'Add New Category' ), 'new_item_name' => __( 'New Category Name' ), 'menu_name' => __( 'Categories' ), ); $args = array( 'hierarchical' => true, // Set this to 'false' for non-hierarchical taxonomy (like tags) 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'categories' ), ); register_taxonomy( 'vacatures_categories', array( 'post_vacatures' ), $args ); } add_action( 'init', 'create_vacatures_taxonomies', 0 );
Thanks for visiting our website. Follow our website because, DataInFlow is a platform, where you can get the text tutorial and video tutorial of a different kind of programming language like PHP, HTML, Javascript, Jquery, CSS3 and get some technology and latest news. View this Tutorial: Integrate recaptcha in contact form 7 in WordPress.