Removing a Parent Theme’s Menu Items

Of course right after I post this, I find an answer…so hopefully someone else can benefit from this. For me, the answer was instead of unregistering nav menu items, I needed to just remove the action…so my function now looks like this: function remove_cornerstone_menus() { remove_action(‘init’, ‘cornerstone_menus’); } add_action(‘init’, ‘remove_cornerstone_menus’); Worked like a charm.

Is it possible to override this function/class in a child theme?

You simply need to run your code on a higher priority than what the parent theme is, the default on add_action function is 10 so you can use: function s157343_unregister_widgets() { unregister_widget( ‘Chocolat_Widget_New_Entrys’ ); } add_action( ‘widgets_init’, ‘s157343_unregister_widgets’, 20 ); This will unregister that widget. Of course, you can still create a new class that … Read more

How to use parent theme’s enqueue methods

If the desired functions are in the parent theme’s functions.php then you can include them in your currently executing child theme functions.php with this call: include( get_template_directory() . ‘/functions.php’); get_template_directory() finds the parent’s directory even when using a child theme. Note that this will run everything found to be executable in the parent theme’s functions.php. … Read more

Get parent theme version

In the WP_Theme class, the get method gives you a sanitized theme header. You cannot use it to extract a property. Actually you don’t need to, as you can access it directly like this: // get the parent object $parent = wp_get_theme()->parent(); // get parent version if (!empty($parent)) $parent_version = $parent->Version;

Get Parent Theme Author Name

Thanks for all the help which pointed me in the right direction. In the end I used the following: $style_parent_theme = wp_get_theme(get_template()); $style_parent_theme_author = $style_parent_theme->get( ‘Author’ ); I use get_template() to recover the folder name of the parent theme. wp_get_theme then get’s the theme object. Once we have that we can manipulate the object to … Read more