Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionto use that code <img src="<?php echo esc_url( get_header_image() ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'title' ) ) ); ?>" />
, i created a functions.php like that
<?php
function get_header_image() {
$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
if ( 'remove-header' == $url ) {
return false;
}
if ( is_random_header_image() ) {
$url = get_random_header_image();
}
}
?>
but it shows error :
Fatal error: Cannot redeclare get_header_image() (previously declared in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\wordpress\wp-includes\theme.php:1058) in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\wordpress\wp-content\themes\html5blank-stable1\html5blank-stable\functions.php on line 13
so how can i solve it?
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 5 years ago.
Improve this questionto use that code <img src="<?php echo esc_url( get_header_image() ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'title' ) ) ); ?>" />
, i created a functions.php like that
<?php
function get_header_image() {
$url = get_theme_mod( 'header_image', get_theme_support( 'custom-header', 'default-image' ) );
if ( 'remove-header' == $url ) {
return false;
}
if ( is_random_header_image() ) {
$url = get_random_header_image();
}
}
?>
but it shows error :
Fatal error: Cannot redeclare get_header_image() (previously declared in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\wordpress\wp-includes\theme.php:1058) in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\wordpress\wp-content\themes\html5blank-stable1\html5blank-stable\functions.php on line 13
so how can i solve it?
Share Improve this question asked Jun 20, 2019 at 6:59 Murat DenizMurat Deniz 77 bronze badges 2 |1 Answer
Reset to default 1The error message is pretty clear in this case.
You can’t have two functions with the same name.
WordPress already has function called get_header_image
, so you can’t call your custom function with this name.
That’s why it’s a good idea to add prefixes to functions you declare in your theme. So instead get_header_image
you call your custom function MYTHEME_get_header_image
(of course replace MYTHEME
with name of your theme).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745385362a4625415.html
get_header_image
is already declared in this file\wp-includes\theme.php
change your function name to something eles likeget_header_image_custom
infunctions.php
file – Parthavi Patel Commented Jun 20, 2019 at 7:04