Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to change a php file in a subdir of my theme folder. The path to that specific file is:
/includes/sf-content-display/sf-post-formats.php

I copied the file within the subdirs in my child theme and made the changes.

It seems, if I read some articles, that I have to hook a selfmade function in a file functions.php in the child theme.

I did the folowing:

function require_once_child() {
    require_once('includes/sf-content-display/sf-post-formats.php');    
}

function require_once_child() {
    remove_action( 'init', 'require_once' );
    add_action( 'init', 'require_once_child' );
}
add_action( 'init', 'require_once_child' );

Result is an error:

Fatal error: Cannot redeclare require_once_child() (previously declared in /www/htdocs/keltenwo/wp/wp-content/themes/flexform-child/functions.php:3) in /www/htdocs/keltenwo/wp/wp-content/themes/flexform-child/functions.php on line 9

Any suggestions?

share|improve this question
1  
You are including a PHP by editing style.css? Please clarify this question. –  s_ha_dum Aug 11 '13 at 16:10
add comment

1 Answer

Any suggestions?

For one, read and interpret the error message.
"Cannot redeclare require_once_child()" is pretty straightforward: Don't give two functions the same name.

I am uncertain whether your general idea is sensible in the first place, but should it be, this

function require_once_child() {
    require_once('includes/sf-content-display/sf-post-formats.php');    
}
add_action( 'init', 'require_once_child' );

is all you need.

share|improve this answer
    
Thanks Johannes, It make sence. I have included this function above but i get the next message: Fatal error: Cannot redeclare sf_get_post_media() (previously declared in /www/htdocs/keltenwo/wp/wp-content/themes/flexform/includes/sf-content-display/s‌​f-post-formats.php:15) in /www/htdocs/keltenwo/wp/wp-content/themes/flexform-child/includes/sf-content-dis‌​play/sf-post-formats.php on line 36 It seems the function sf_get_post_media() is already declared. –  go4wordpress Aug 12 '13 at 9:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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