admin管理员组文章数量:1022736
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' );
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
That indeed contains a syntax error. You should use concatenation like so:
'[footer_copyright] ' . get_bloginfo( 'name' );
– Sally CJ Commented Apr 19, 2019 at 23:39 - 1 Worked like a charm, thank you. If you post that as an answer I'll accept it! Cheers – anonymoose Commented Apr 20, 2019 at 4:24
- 1 I've done that. :) – Sally CJ Commented Apr 20, 2019 at 4:59
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' );
本文标签: Issue echoing the site39s title in Genesis child theme
版权声明:本文标题:Issue echoing the site's title in Genesis child theme 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745571344a2156756.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
'[footer_copyright] ' . get_bloginfo( 'name' );
– Sally CJ Commented Apr 19, 2019 at 23:39