This is a function loaded by the parent theme. Through the child theme, I want to change this function to say is_single instead of is_singular. What would be the correct way to achieve this?

add_action('wp_head', 'dt_specific_enqueues');
function dt_specific_enqueues() {

    if (is_singular()) {
        wp_enqueue_script( 'comment-reply' );


2 Answers 2


The parent theme's functions.php will load automatically. You don't need to "read" it, and you don't want to "hack" it either manually, which will be overwritten, or programatically, which is very resource intensive.

Your theme is enqueueing the script on the wp_head action. You just need to remove that callback and add a slightly modified one. The trick is that your child theme's functions.php loads after your parent functions.php so you need to get the timing right.

function dequeue_dt_specific_enqueues() {
  remove_action('wp_head', 'dt_specific_enqueues');
add_action('after_setup_theme', 'dequeue_dt_specific_enqueues');

Then add back your own version:

function altered_dt_specific_enqueues() {
  if (is_single()) {
    wp_enqueue_script( 'comment-reply' );
add_action('wp_head', 'altered_dt_specific_enqueues');

You can use remove_action to remove a particular action done by your parent theme (within your child theme, before adding your own action to that hook [wp_head]) and then add your own action with add_action in your child theme.


Remove Action

Add Action

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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