Override the function twentytwelve_scripts_styles in a child theme

If you want to remove the entire twentytwelve_scripts_styles function, you have to remove the action hook : remove_action( ‘wp_enqueue_scripts’, ‘twentytwelve_scripts_styles’ ); However, this code have to execute after the function is being hooked by Twenty Twelve code, and before the action is fired (because after it’s too late). The child theme functions.php file is loaded … Read more

Automatically include all php files in a child theme directory

I suspect glob needs the current working directory to work, so you could try passing the full path of the file to the existing function you have… include_all_php(dirname(__FILE__).’/includes’); Or set the current working directory first: setcwd(dirname(__FILE__).”https://wordpress.stackexchange.com/”); include_all_php(‘includes’); Alternatively you could also use scandir: $filepath = dirname(__FILE__).’/includes/’; $files = scandir($filepath); foreach ($files as $file) { // … Read more

Reuse variable in hook callback

If you want to use a variable from a another context in a function, create a class: class CustomLog { private $debug_msg = “”; public function __construct( $msg ) { $this->debug_msg = $msg; } public function log() { error_log( $this->debug_msg, 0 ); } } add_action( ‘init’, [ new CustomLog( “Hi there!” ), ‘log’ ], 20 … Read more

How to show only next post pagination link using wp_link_pages()

Here’s a suggestion, using the wp_link_pages_link filter to remove the previous links: add_filter( ‘wp_link_pages_link’, function( $link, $nextorprev ) { return get_query_var( ‘page’ ) > $nextorprev ? ” : $link; }, 10, 2 ); We can also create a plugin that removes empty previous/next links. So if we have one of the following: ‘nextpagelink’ => ”, … Read more

Creating child-theme from other template files

For your specific theme this question cannot be answered without analyzing all template files. More in general, a theme structured like this is almost impossible to make a child theme for. Take footer.php. If you just put that in your child theme it will be called at the appropriate moment. But if that file tries … Read more