Custom-Taxonomy as categories: Remove “most-used” tab?

Yes – you need to first ‘de-register’ the metabox WordPress automatically creates: add_action( ‘admin_menu’, ‘myprefix_remove_meta_box’); function myprefix_remove_meta_box(){ remove_meta_box(‘my-tax-metabox-id’, ‘post’, ‘normal’); } Where my-tax-metabox-id is the ID of your metabox. Then ‘re-register’ the metabox providing your own callback function which produces in the output: //Add new taxonomy meta box add_action( ‘add_meta_boxes’, ‘myprefix_add_meta_box’); function myprefix_add_meta_box() { add_meta_box( … Read more

How to auto send email when publishing a custom post type?

Hook into transition_post_status, fetch the users and send an email to all users. Sample code, not tested: add_action( ‘transition_post_status’, ‘send_mails_on_publish’, 10, 3 ); function send_mails_on_publish( $new_status, $old_status, $post ) { if ( ‘publish’ !== $new_status or ‘publish’ === $old_status or ‘my_custom_type’ !== get_post_type( $post ) ) return; $subscribers = get_users( array ( ‘role’ => ‘subscriber’ … Read more

custom post type taxonomies UI radiobuttons not checkboxes

When you register a taxonomy WordPress automatically handles producing the appropriate metabox. First you need to ‘de-register’ this default metabox: add_action( ‘admin_menu’, ‘myprefix_remove_meta_box’); function myprefix_remove_meta_box(){ remove_meta_box(‘my-tax-metabox-id’, ‘post’, ‘normal’); } Where my-tax-metabox-id is the ID of your metabox. Then ‘re-register’ the metabox providing your own callback function which produces in the output: //Add new taxonomy meta … Read more

Exclude custom function content from certain pages

Check for the type of the page: function get_author_bio ($content=””){ if ( ! is_single() ) // not a blog post, stop immediately { return $content; } global $post; // continue with regular work The easiest way to learn these check functions is a look at the function get_body_class(). Here are the most important: is_rtl() is_front_page() … Read more

Pass parameter to custom post type single while keeping clean url

you can add this parameter in URL with this code to put after registering the custom post type : add_rewrite_tag(‘%location%’, “([^&]+)”); $slug = get_post_type_object(“services”)->rewrite[“slug”]; $query_var = get_post_type_object(“services”)->query_var; add_rewrite_rule( “$slug/([^&]+)/([^&]+)$” , “index.php?$query_var=\$matches[1]&location=\$matches[2]” , “top” ); after adding this in your plugin, you need to flush rewrite rules once : https://codex.wordpress.org/Function_Reference/flush_rewrite_rules then you can read the location … Read more