Mike Waller
asked on
change url based on site domain
Hi there. I am running a WordPress Multi-site and need to change the url on a logo on only 1 site. I am using the following but I think I have it wrong:
Any ideas experts?
<?php
if (isset($_GET['url']) && $_GET['url'] === 'http://domain.org')
{
echo "<a href="https://otherdomain.org"><?php FLTheme::logo(); ?></a>";
{
else
echo "<a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php FLTheme::logo(); ?></a>";
}
}
?>
Any ideas experts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Ryan Chong. Your solution seemed to work best although the logos don't click through. It's as if there is no link around the logos.
Ray, your code broke the site. Any ideas why?
Ray, your code broke the site. Any ideas why?
No, sorry. I don't have any way to test, so I can't know what is wrong unless you can show me the error message or the log files. "Broke the site" isn't adequate for debugging.
ASKER
Ray, the site went blank white. I put your code in here http://phptester.net/ and I see this error:
FATAL ERROR syntax error, unexpected 'https' (T_STRING), expecting ',' or ';' on line number 6
FATAL ERROR syntax error, unexpected 'https' (T_STRING), expecting ',' or ';' on line number 6
I don't see any parse error, sorry. I have the script installed here:
https://www.iconoun.com/demo/temp_cowebmaster.php
The output might not be right yet, and might need some adjustment.
https://www.iconoun.com/demo/temp_cowebmaster.php
The output might not be right yet, and might need some adjustment.
ASKER
Ray, okay I got this to work if I use single quotes:
However, the line of text FLTheme::logo() appears on the page and not the actual image. Any ideas?
<?php
error_reporting(E_ALL);
if (isset($_GET['url']) && $_GET['url'] == 'http://domain.org')
{
echo "<a href='https://otherdomain.org'>FLTheme::logo()</a>";
}
else
{
echo "<a href='esc_url( home_url( '/' ) )'>FLTheme::logo()</a>";
}
However, the line of text FLTheme::logo() appears on the page and not the actual image. Any ideas?
It may be necessary to assign the output of esc_url() and FLTheme::logo() to local variables and put those variables into the anchor tags.
ASKER
Thanks Ray, I have no idea how to do that. Can you give an example?
depending on what the function dose you should beable to
Then you can reference the variable $logo_data instead of the function. Same with
$logo_data = FLTheme::logo();
Then you can reference the variable $logo_data instead of the function. Same with
$str_url = esc_url( home_url( '/' ) );
Your solution seemed to work best although the logos don't click through. It's as if there is no link around the logos.can you tell what's the HTML codes generated from my comment in ID: 41948355 ?
ASKER
Ryan, the image displays on the page but there is no hyperlink surrounding the image:
<img class="fl-logo-img" itemscope="" itemtype="http://schema.org/ImageObject" src="http://domain.org/path-to-file/logo.png" data-retina="" alt="">
<img class="fl-logo-img" itemscope="" itemtype="http://schema.org/ImageObject" src="http://domain.org/path-to-file/logo.png" data-retina="" alt="">
ASKER
Open in new window
^ does it make sense?
So I have the following and the site breaks:
Open in new window
What am I doing wrong?