Jump to content

I want to a show a picture on a page depending on the url that the user is seein


kiddink

Recommended Posts

I want to show a picture of a dog, if the page that im on is mywebsite.com/dog

 

now this sounds easy but im using wordpress. which basically only has like,

 

index.php, sidebar.php, etc etc

 

and basically it builds the pages on the fly, depending on which category I choose.

 

so in my sidebar.php, i need some sort of code that says:

 

if(currenturl = theurlIpicked)

<img src = blah blah>

else

blah blah

 

that way when the sidebar.php loads, if the url isn't the one that I want, it just won't load that image.

 

i have 0 php knowledge so I need you guys's help :(

 

thanks again

why dont you just add the image on the respective page ?

 

you didn't read my post did you?

 

im using wordpress which is basically like a blogging tool.

 

i have 8 php files. archives, post, welcome.php, index.php, sidebar, main index template, etc etc etc

 

so there is no .php file or .html for an actual page. at least i cant access it or i dunno how?

 

is there a code that checks for the url?

how many pages do you have on a .php file?

can you post a link to the page?

 

the website is things4cheap.com, you'll be redirected to different pages such as things4cheap.com/categories/baby-items,

 

but i do not have a baby-items.php FILE, it builds everything in real time.

anybody?

 

c'mon guys this is probably so easy for you like,

 

if(myurl == "chosenurl")

{

}

 

just give me the php if statement with that condition and i know how to do the rest. it's just i have 0 coding experience in php.

do you know  how to rename the index page with the category links ?

for example to modify this link from

http://things4cheap.com/categories/baby-items

to:

http://things4cheap.com/categories/baby-items?img=+

<?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;
}
?>

 

<?php
if(curPageURL() == 'http://yourwebsite.com/category/dog')
{
  echo '<img src="" />';
}
?>

 

Should work, didn't test it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.