0

I've got a custom metabox written for another site that I'm porting over, originally this was written directly onto the theme (rather than using a child theme).

The metabox itself was developed using the wpalchamey metabox framework.

If I port the files into the main theme the meta box works correctly, but when I port it into the child theme 90% of it works, including the containing <div> and the title of the metabox / postbox (but not the actual form inputs); the views also work.

I'm guessing this has something to do with the referenced files, includes etc, were they are trying to find a file in maintheme/lib/metabox where they should be looking for maintheme-child/lib/metabox.

I've been going round for the last hour or so and can't see where the issue lies; any ideas where I may be able to resolve this issue?


PS. I'm using WP4.0

0

I found the answer my self, the issue had to do with a line requesting the content of the metabox (as expected). The line:

'template' => get_template_directory() . '/lib/metaboxes/custom_textbox.php',

should have been changed to:

'template' => get_stylesheet_directory() . '/lib/metaboxes/custom_textbox.php',

According (to the WordPress Codex) will get the path for the main theme. If you want to access the child theme URl (even if your in the child theme apparently) you have to use get_stylesheet_directory() (which I personally find the function name a little confusing as it's a child theme directory that can be used for a lot more that just a custom stylesheet).

Further reading in Codex: get_template_directory(), get_stylesheet_directory()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.