Action hook - what is wrong here?
My last try to get some help here... Maybe my other thread did not describe good enough what my problem is. So again:
I'm sitting on a child-theme and must do a small change in the header area that shows "Ad an Post". That code is located in the
/includes/theme-header.php at line 124. So far, so good. In order to get my child-theme work as i want i need an additional small code like this:
<div class="header_menu">
<div class="header_menu_res">
<a href="<?php echo CP_ADD_NEW_URL ?>" class="obtn btn_orange"><?php _e('Post an Ad', 'appthemes') ?></a>
<a href="<?php echo CP_ADD_NEW_URL ?>" class="sam_test"></a>
The green part is the one i need to get working in my child-theme.
Now comes my problem with the action hooks! These are the steps i did:
I created a empty functions.php and added this code:
PHP Code:
<?php
/**
* Write your own functions or modify functions, actions, and filters using this file.
* LIST YOUR FUNCTIONS (optional):
* cp_import_wp_childstyle() [CUSTOM]
* cp_get_price() [OVERWRITE]
*/
//Place All Your Custom Function Below This Line
//Do not place any code below this line.
?>
I uploaded that functions.php to my child-theme directory. No problems so far.
Now i would like to have my own theme-header.php which has the same content like the original + that small code from above (the green one). So i copied the complete content of the theme-header.php, added my small code in the right place and named that new file
my-header.php. Now i upload this
my-header.php to my main child-theme directory. So far everything ok?
Now i add the following code to my functions.php:
PHP Code:
<?php
/**
* Write your own functions or modify functions, actions, and filters using this file.
* LIST YOUR FUNCTIONS (optional):
* cp_import_wp_childstyle() [CUSTOM]
* cp_get_price() [OVERWRITE]
*/
//Place All Your Custom Function Below This Line
function unhook_appthemes_functions() {
// unload the default ClassiPress theme header
remove_action( 'appthemes_header', 'cp_header' );
}
add_action('init','unhook_appthemes_functions');
// let's add our own header instead
function my_theme_header() {
// do something here
}
add_action( 'appthemes_header', 'my-header' );
//Do not place any code below this line.
?>
If i call my site now, everything is ok
BUT the complete header is gone - just not there. What in hell is wrong? If i make a change at the part function
my_theme_header() {
...the site brings me a "500" Error. The word "my_theme_header" is needed? Why does it not call my
my-header.php ?
So far it seems that the functions.php is working and calling, but i must have a missunderstanding how to call my own my-header.php from there.
Please, if somebody knows what is wrong here, give me the right way. I would really appreciate a little help.
Samcy