• Resolved pangalanrao

    (@pangalanrao)


    I am using customizr theme. For all regular posts and pages the header part (get_header) loads properly. I have a custom post_type as assignments which is created through a plugin. While loading those post type the header doesn’t load at all. I debugged myself and found that header.php has several do_action which are not working in case of custom post type. The plugin has separate template for post_type and in that get_header(); is mentioned. This issue is only related to customizr theme while in other themes everything works fine. Other than changing the theme is there any solution?

Viewing 2 replies - 1 through 2 (of 2 total)
  • What’s this plugin?

    Do you have a child-theme?
    If yes, and that plugin uses the template_redirect hook with a priority value greater than 0 (so lower priority), add the following to your child-theme functions.php:

    add_action('after_setup_theme', 'rehook_header_hooks');
    function rehook_header_hooks(){
      if ( ! ( method_exists('TC_header_main', 'tc_set_header_hooks') && method_exists('TC_header_main', 'tc_set_header_options') ) )
        return;
    
      remove_action ( 'template_redirect' , array( TC_header_main::$instance , 'tc_set_header_hooks' ) );
      remove_action ( 'template_redirect' , array( TC_header_main::$instance , 'tc_set_header_options' ) );
      add_action ( 'template_redirect' , array( TC_header_main::$instance , 'tc_set_header_hooks' ), 0 );
      add_action ( 'template_redirect' , array( TC_header_main::$instance , 'tc_set_header_options' ), 0 );
    
    }

    Otherwise one should look at the plugin code. If is a payed plugin you should ask to their support forum, I think.

    Hope this helps.

    Thread Starter pangalanrao

    (@pangalanrao)

    Thanks man!
    You saved my day. I have added your codes to functions.php of the plugin and it is now working fine.
    As you said the plugin was using get_template_part with low priority.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘do_action in header works for regular post but not for custom post type’ is closed to new replies.