I'm having an issue adding a dynamic site name/title to the footer with my Genesis theme. From their shortcode reference I've gathered that I should, I think, be able to add it in the below code in place of the Editable Link. Here's what I mean:
//* Change the footer text
add_filter('genesis_footer_creds_text', 'sp_footer_creds_filter');
function sp_footer_creds_filter( $creds ) {
$creds = '[footer_copyright] <a href="/">Editable Link</a>';
return $creds;
}
However, when I replace the Editable Link text with something like $creds = '[footer_copyright] <?php echo get_bloginfo( 'name' ); ?>';
I get:
Your PHP code changes were rolled back due to an error on line 291 of file wp-content/themes/genesis-sample-develop/functions.php. Please fix and try saving again.
syntax error, unexpected 'name' (T_STRING)
I've tried several variations of <?php echo get_bloginfo( 'name' ); ?>
but nothing seems to want to work. What am I missing?
I'm having an issue adding a dynamic site name/title to the footer with my Genesis theme. From their shortcode reference I've gathered that I should, I think, be able to add it in the below code in place of the Editable Link. Here's what I mean:
//* Change the footer text
add_filter('genesis_footer_creds_text', 'sp_footer_creds_filter');
function sp_footer_creds_filter( $creds ) {
$creds = '[footer_copyright] <a href="/">Editable Link</a>';
return $creds;
}
However, when I replace the Editable Link text with something like $creds = '[footer_copyright] <?php echo get_bloginfo( 'name' ); ?>';
I get:
Your PHP code changes were rolled back due to an error on line 291 of file wp-content/themes/genesis-sample-develop/functions.php. Please fix and try saving again.
syntax error, unexpected 'name' (T_STRING)
I've tried several variations of <?php echo get_bloginfo( 'name' ); ?>
but nothing seems to want to work. What am I missing?
1 Answer
Reset to default 1Your code indeed contains a syntax error, which is unescaped quotes:
$creds = '[footer_copyright] <?php echo get_bloginfo( 'name' ); ?>'; // bad - ' not escaped
$creds = '[footer_copyright] <?php echo get_bloginfo( \'name\' ); ?>'; // good - ' escaped
But even if you escape the quotes, the code will not work as expected.
So to make it work as expected, use concatenation like so:
$creds = '[footer_copyright] ' . get_bloginfo( 'name' );
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745571346a4633701.html
'[footer_copyright] ' . get_bloginfo( 'name' );
– Sally CJ Commented Apr 19, 2019 at 23:39