Skip to content

Instantly share code, notes, and snippets.

@salcode
Created July 16, 2016 16:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salcode/be98a45d42c78ca96229b02f567caa33 to your computer and use it in GitHub Desktop.
Save salcode/be98a45d42c78ca96229b02f567caa33 to your computer and use it in GitHub Desktop.
<?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' => apply_filters( 'fe_accomodatinos_label', __( 'Accommodations', 'fe_recipe' ) ),
'public' => true,
'has_archive' => true,
'rewrite' => array(
// Slug should be plural and L10n ready.
'slug' => apply_filters( 'fe_accommodations_slug', _x( 'accommodations', 'CPT permalink slug', 'fe_recipe' ) ),
'with_front' => false,
),
/**
* 'title', 'editor', 'thumbnail' 'author', 'excerpt','custom-fields',
* 'page-attributes' (menu order),'revisions' (will store revisions),
* 'trackbacks', 'comments', 'post-formats',
*/
'support' => array( 'title', 'editor' ),
// Url to icon or choose from built-in https://developer.wordpress.org/resource/dashicons/.
'menu_icon' => 'dashicons-feedback',
) );
}
@salcode
Copy link
Author

salcode commented Jul 16, 2016

add_filter( 'fe_accommodations_slug', 'fe_accommodations_slug_to_rooms' );

function fe_accommodations_slug_to_rooms( $slug ) {
   return 'rooms';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment