Register custom_post_type from static function

Since the activation hook only will be called when activating the plugin, you will instead need to call register_post_type() on some hook which is triggered every time you access the administration pages. You could use the init hook for this: add_action(‘init’, array($this, ‘register_custom_type’)); You also need to make the register_custom_type() method public for this to … Read more

Default excerpt for parent of a custom post type

This will default the excerpt value in your custom post type only for new posts: add_filter( ‘default_excerpt’, ‘smyles_default_custom_post_excerpt’, 10, 2 ); /** * Default Excerpt for Custom Post Type * * @param string $post_excerpt Default post excerpt. * @param WP_Post $post Post object. * * @return string * */ function smyles_default_custom_post_excerpt( $post_excerpt, $post ){ if( … Read more

Post template not applying on theme (potentially rendering as Page template)

Fixed it! I have now created a single folder in my theme’s directory and put category specific templates in there. To enable this, I added this to the theme’s function file /* * Define a constant path to our single template folder */ define(SINGLE_PATH, TEMPLATEPATH . ‘/single’); /** * Filter the single_template with our custom … Read more

Action on Custom Post publish

Issue is resolved Updated Code <?php /* Plugin Name: Send Notification CPT Description: Declares a plugin that will create a custom post type to send notifications. Version: 1.0 */ if( ! defined(‘ABSPATH’)) { exit; } // Register Custom Post Type Send Notifiction function create_sendnotifiction_cpt() { $labels = array( ‘name’ => _x( ‘Send Notifiction’, ‘Post Type … Read more