-
-
Save salcode/f254267c7b2f57364f7c2929d699a856 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The code to register a WordPress Custom Post Type (CPT) `fe_recipe` | |
* with a custom Taxonomy `fe_recipe_tag` | |
* @package fe_recipe | |
*/ | |
add_action( 'init', 'fe_recipe_cpt' ); | |
/** | |
* Register a public CPT and Taxonomy | |
*/ | |
function fe_recipe_cpt() { | |
// Post type should be prefixed, singular, and no more than 20 characters. | |
register_post_type( 'fe_recipe', array( | |
// Label should be plural and L10n ready. | |
'label' => __( 'Recipes', 'fe_recipe' ), | |
'public' => true, | |
'has_archive' => true, | |
'rewrite' => array( | |
// Slug should be plural and L10n ready. | |
'slug' => _x( 'recipes', 'CPT permalink slug', 'fe_recipe' ), | |
'with_front' => false, | |
), | |
// Add support for the new block based editor (Gutenberg) by exposing this CPT via the REST API. | |
'show_in_rest' => true, | |
/** | |
* 'title', 'editor', 'thumbnail' 'author', 'excerpt','custom-fields', | |
* 'page-attributes' (menu order),'revisions' (will store revisions), | |
* 'trackbacks', 'comments', 'post-formats', | |
*/ | |
'supports' => array( 'title', 'editor', 'custom-fields' ), | |
// Url to icon or choose from built-in https://developer.wordpress.org/resource/dashicons/. | |
'menu_icon' => 'dashicons-feedback', | |
) ); | |
register_taxonomy( | |
'fe_recipe_tag', | |
'fe_recipe', | |
array( | |
// Label should be plural and L10n ready. | |
'label' => __( 'Recipe Tags', 'fe_recipe' ), | |
'show_admin_column' => true, | |
'rewrite' => array( | |
// Slug should be singular and L10n ready.. | |
'slug' => _x( 'recipe-tag', 'Custom Taxonomy slug', 'fe_recipe' ), | |
), | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment