php - Override metaboxes from parent theme in child theme in WordPress -


i have parent theme in wordpress adds many functions , features wordpress, including several metaboxes.

in child theme, have added new custom post types wordpress, trying modify meta boxes include them in new custom post types.

here parent theme functions.php file: http://pastebin.com/g1cvm6u2

my thought need add code child theme remove action parent theme adds in metaboxes, , copy metabox files child theme, modify them needed, , use add_action pull in new function calls metabox files.

however, having hell of time being able remove action parent theme.

i have tried several variations of following in child theme functions.php:

remove_action('init', 'add_metaboxes'); remove_action('add_meta_box', 'add_metaboxes'); 

it not remove metaboxes though, when check page/post editor, still visible.

without running remove_action, cannot new "add_action" call in modified metabox files. when try so, white screen of death due guess same function being redeclared.

i suspect because action in parent theme being called part of class, process of over-riding in child theme might differet?

would appreciate on one.

sample 1: remove normal named add action

add_action('after_setup_theme', 'remove_meta_boxes');  function remove_meta_boxes(){      remove_action('add_meta_box', 'add_metaboxes'), 10; } 

sample 2: remove function passed reference

the add_action looks this:

class ab{      function __construct(){         add_action('init', array( &$this, 'add_metaboxes' ));     }    }   $x=new ab; 

the problem here wordpress prepend random identification string function name e.g. (a3898orj34930add_metaboxes), random every time need use strpos find name in key. have created custom function this.

function remove_anon_filters( $name, $functionname, $priority){     global $wp_filter;      foreach ( $wp_filter[$name][$priority] $key => $data) {          if( stripos($key, $functionname )  ){             remove_action( $name, $key, $priority  );         }       }    } 

we hook after theme set remove parent theme action.

 add_action('after_setup_theme', 'remove_parent_meta_boxes');   function remove_parent_meta_boxes(){     remove_anon_filters ( 'init', 'add_metaboxes', 10);  } 

Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

How to use Authorization & Authentication in Asp.net, C#? -