Support » Themes and Templates » Running a child function after parent theme function

  • fcb66



    I am using WooThemes Simplicity theme, but I have been asked to work on a site that uses it, so I didn’t purchase it and so don’t have access to their documentation or forum.

    Anyway, I have created a child theme in order to add a custom post type. I now want to add some of wootheme’s own meta boxes to it. I can do this by adding the relevant code to the right file in Simplicity, but when I try to extract it out to my child theme files it does not work.

    This is because the child functions.php file is processed before the parent files and the parent theme blitzes my child theme’s settings as a result.

    I have looked for an action hook that will allow me to run my function after the parent finishes setting up, but so far nothing seems to work as expected.

    Has anyone got any pointers or tips on how to get this to work?


Viewing 1 replies (of 1 total)
  • Hello

    I had a similar problem recently. In my child theme, based on Twenty Eleven, I wanted to completely replace the default set of header images with my own, which meant finding a way to get some code to run after the parent theme.

    I achieved what I wanted by adding an action to the “after_setup_theme” hook and — here’s the key — passing a value for add_action‘s 3rd, “priority” parameter. You may need — or want — to experiment, or trace your code somehow, to get the priority right, but it’s likely you’ll get away with just passing an arbitrary, large number.

    Here’s the sort of think you’re looking for:

    add_action( 'after_setup_theme', function() {
        //Do something
    }, 42 );
Viewing 1 replies (of 1 total)
  • The topic ‘Running a child function after parent theme function’ is closed to new replies.