0

I've been working on a site for someone and I've been debating whether or not to take a risk with something. I haven't really worked a lot with .php in the past, but I know that a few mistakes in there can screw a lot of things up massively. I want to change the alt-tag for the logo that's displayed and usually they just had a normal alt-tag in the past. Now I've come across a .php-file which has ".$site_title." as an alt-tag and I don't want to screw anything up on his live website. Is it possible for me to change that part into something else without any problems, or will it screw something up massively if it isn't something specific? Might seem like a big noob-problem, but my past projects haven't really brought me close towards .php and I'd better be safe than sorry.

If it helps: the theme that's used is "Flatsome", so the alt-tag is inside the "element-logo.php". And if anything else is needed, I'll happily provide it.

Thanks in advance!

3
  • Can you post the entire snippet that has the .$site-title. so we can get a bigger picture. Just a note though, using a commercial theme like Flatsome, you don't want to edit the core files with that theme, so you may have a bit of an issue. If you still have time you should consider building it out as a child theme. You may also want to check with Flatsome's development team in case there's a hook or an option built in that will allow you to do this. Commented Apr 15, 2020 at 22:14
  • The entire thing for the logo and the alt-tag is class="header-logo-dark" alt="'.$site_title.'"/>'; and that repeats for all the versions of the logo. Sadly I don't really have a lot of time on my hands anymore, so getting into contact with the development team isn't an option.
    – perphhh
    Commented Apr 16, 2020 at 12:47
  • And just in case you meant the whole line: if(!get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header-logo-dark" alt="'.$site_title.'"/>';
    – perphhh
    Commented Apr 16, 2020 at 13:02

1 Answer 1

0

Use the following code to replace the original code:

if(!get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header-logo-dark" alt="your alt information here" />';

i.e. you're replacing alt="'.$site_title.'" with alt="your alt information here".

What the '.$site_title.' means is the echo statement ends at the ' and then the PHP variable $site_title is appended to the string, and then the string reopens with the '. The . is a string concatenation character in PHP.

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.