0

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?

3
  • 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 1

1

Your 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' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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