Not sure what that code above refers to.
If you want to remove a script set by the parent theme, use:
http://codex.wordpress.org/Function_Reference/wp_deregister_script
The script you’re looking to remove is loaded like this:
wp_enqueue_script( 'themejs', get_template_directory_uri() . '/js/theme.js', array( 'jquery' ), false, true );
Devin, in the functions.php file of the parent folder the scripts are registered with a single function:
/**
* Loads the required javascript for the drop down menus and jquery effects
* on portfolio items and post formats.
*/
function portfoliopress_scripts() {
wp_enqueue_script( 'superfish', get_template_directory_uri() .'/js/superfish.js', array( 'jquery' ), false, true );
if ( !is_single() ) {
wp_enqueue_script( 'themejs', get_template_directory_uri() . '/js/theme.js', array( 'jquery' ), false, true );
}
}
add_action('wp_enqueue_scripts', 'portfoliopress_scripts');
I thought it made sense to disable the “portfoliopress_scripts” function so I could replace it with my own version of the scripts.
Mark
Sure, you could do that if you want to re-enqueue superfish.
Then just use remove_action in your child theme:
remove_action('wp_enqueue_scripts', 'portfoliopress_scripts',100);
So here is what I have. It is still taking the theme.js from the parent directory.
function my_deregister_parentTheme() {
wp_deregister_script( 'theme.js' );
}
add_action( 'wp_print_scripts', 'my_deregister_parentTheme', 100 );
function bptArtTrail_script() {
if ( !is_single() ) {
wp_enqueue_script( 'themejs', get_template_directory_uri() . '/js/theme.js', array( 'jquery' ), false, true );
}
}
add_action('wp_enqueue_scripts', 'bptArtTrail_script');
For now I have modified the theme.js file inside the parent folder. I have a modified copy of the theme.js file inside a js directory in my child theme folder. How do I get the theme to pull the theme.js content from the child folder?
Mark
In child theme:
wp_deregister_script( 'themejs' );
wp_enqueue_script( 'customthemejs', get_stylesheet_directory_uri() . '/js/customtheme.js', array( 'jquery' ), false, true );
Assumes you change the name of the js file to customtheme.js in your child theme.
Thanks Devin but unfortunately it didn’t work. As per your instructions,
- I changed the name of “theme.js” to “customtheme.js” in my child theme’s js folder.
- I then replaced the code I had before with your code in my child theme’s functions.php.
- The last step was to restore theme.js in the parent folder to its original state.
As soon as I did that the portfolio item’s hover behavior took on the parent theme’s jquery behaviors.
For now I have put my modified jquery code back into theme.js.
Hello,
I have long used the child theme with many mods in style.css and functions.php files that are complementary to those present in the parent theme. From this side, no problem …
But it is written everywhere that the other files included in the child theme (eg, footer.php, header.php, etc. …) take precedence over files in the parent theme.
What if the update of the parent theme among other concerns, the files in the child theme?
It therefore receives more than the update?
Am I mistaken or not?
Thank you for your answers.
Excuse me for my english
Best regards
Alain
Website : http://www.modelisme-racer.fr/
Please post your own topic. You are using a completely different themes.
Alain, to answer your question, I put a copy of the Portfolio Press functions.php in my child theme folder so I could modify the functions I wanted. I, like you believed that the child theme’s functions would take precedence over the parent theme but all it did was break the site. So until I have another solution, I will need to modify the parent theme’s functions and jquery to get the results I want.
Mark