Jump to content

Else/if problem


Certis

Recommended Posts

Hopefully people here know an easy solution to a problem I'm having.

 

First of all, I'm using a script in Wordpress to retrieve the current url. Then I use a code in a link, adding a little code after it, which would switch the theme of my Wordpress (basically, "currenturlcode&wptheme=Sidebar%20disabled").

 

It works great, thanks to that, people will remain on the same page they are and switch the theme. However, if that is clicked on the main page, it goes to the 404 page, cause it needs to use "?" instead of "&" in case of that.

 

So what I need help with here, is somehow making my link see if they are on the main page, and if so, adding "?wptheme=Sidebar%20disabled" there, on other cases"&wptheme=Sidebar%20disabled".

Link to comment
Share on other sites

Of course.

 

This one is the code that is needed, the "brains" of the url getting, I assume.

 

<?php
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>

 

 

And this is the link code I use (including with the php url get function.

 

<a href="<?php echo curPageURL(); ?>&wptheme=Sidebar%20disabled">Click here</a>

Link to comment
Share on other sites

Sorry for replying so late, I was dragged to another town by my relatives, and I did not have access to internet there.

 

Unfortunately, that solution does not work, instead, I get this error line:

 

Fatal error: Can't use function return value in write context in /home/certis/domains/certislp.co.cc/public_html/wp-content/themes/atahualpa169/footer.php on line 24

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.