I have a piece of code
that gets an avatar from wordpress plug ins. I would have used the built in wordpress plug in modules but seems buggy. I want to use this to call the icon only when relevant. Not sure I understand this completely but it works, somewhat! The problem is the else at the end seems to always give some unexpected results, or I never get there, not sure which.
we only use author and page listings so there is always ?author= or ?p= variable unless on the main page.
Code: Select all
<?php
echo $_GET["p"]; // for my diagnostic only
echo $_GET["author"]; //for my diagnostic only
if (!isset($_GET['p']))
{
echo get_avatar( get_the_author_email(), '150' );
}
elseif (!isset($_GET['author']))
{
echo get_avatar( get_the_author_email(), '150' );
}
else
{
}
?>The problem is that when there is no variable defined it shows, for some unknown reason an irrelevant avatar.
SO we go to step 2, or step 0 as it would go before this
Code: Select all
<?php
function getAddress()
{
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
echo getAddress(); // the echo is for diagnostic purposes onlyI need to be able to use this to put together if a URL has no variable or as may be the case on some predetermined addrresses. I can show a generic avatar when the address is at http://www.mydomain.com/
in my case I need to be able to do this also from sub.mydomain.com and sub2.mydomain.com , hence supress the avatar when at the main page.
I need to be able to use IF luike this
Code: Select all
if (getAddress() == http://www.mydomain.com
{ (load a generric or blank icon from an image file from html) // how??
}
//then go on to
elseif (!isset($_GET['p']))
{
echo get_avatar( get_the_author_email(), '150' );
}
else (!isset($_GET['author']))
{
echo get_avatar( get_the_author_email(), '150' );
} I would appreciate any help as I seem to not be able to get this right after too much time wasted on it.
thanks in advance