How to link image to link

Hello Im new to this.

I need help with linking the top image on my site (amifat.org) to a specific link but don’t know what of the code to edit. Could someone be of assistance please?

Hi Kaplan_T4. Welcome to the forums.

It’s not really clear which image you mean, but the image at the top left is already linked. The syntax is:

<a href="http://address-to-link-to.com"><img alt=""></a>

In other words, you wrap a link around the image and in the href=“” attribute you enter a URL.

hi ralph thanks for the reply.

Im sort of lost on where exactly to edit in the wordpress editor. I put the image (the massive one at the top) in the header.php section:

<div id=“header”>

&lt;div class="headerleft"&gt;
	&lt;a href="&lt;?php echo get_option('home'); ?&gt;/"&gt;&lt;img src="&lt;?php bloginfo('template_url'); ?&gt;/images/spsheader.png

" alt=“<?php bloginfo(‘name’); ?>” /></a>
</div>

It links to the homepage. I want to link it to somewhere else but don’t know how. Could you tell me what exactly to change in the code please? If its even the header.php I have to change.

Do you have any include()'s or require() functions in the PHP code for the file?

First thing is you need to look at this line. <a href=“<?php echo get_option(‘home’); ?>/”>

That basically determines the anchors link by using the get_option() function using a parameter of ‘home’. You need to find if the function is defined in the current wordpress file you are in and then post it here and we can go from there (if you can’t figure it out). IF THE FUNCTION IS NOT THERE, there should be some sort of include() or require() or something like that. Check EACH FILE for the function, and when found, post hte function here.

This is now a PHP question so I will ask for a thread move, however I’ll follow you along this path of your question until it’s solved to make sure it’s done :).

Hey thanks for the help!

I know Im going to sound like a dork, but how is it exactly defined? What am I looking for? Im totally new so forgive me!

Do a CTRL+F search to find any text that has the word “include” or “require” in the current page. There should then be parenthesis (). Inside the parenthesis there should be a URL.

Although first, before checking for the “include”'s or “require”'s, see if the function exists (do a CTRL+F search in the file for get_option, and if it’s there, copy paste it).

Here is an example include() statement.

include(“page.php”);

You need to change the portion marked in red.

[COLOR=#464646][FONT=Helvetica Neue]<a href="[/FONT][/COLOR][COLOR=#b22222][FONT=Helvetica Neue]<?php echo get_option('home'); ?>/[/FONT][/COLOR][COLOR=#464646][FONT=Helvetica Neue]"><img src="<?php bloginfo('template_url'); ?>/images/spsheader.png[/FONT][/COLOR]
[COLOR=#464646][FONT=Helvetica Neue]" alt="<?php bloginfo('name'); ?>" /></a>[/FONT][/COLOR]

OK so I done the search you stated and these 2 came up:

<a href="<?php echo get_option(‘home’)

<?php $ad_468 = get_option(‘revlifestyle_ad_468’); echo stripslashes($ad_468) this ones irrelevant as its for an ad.

That’s not it. That’s basically the same as your first code snippet with the <a><img></a>. Calling the same function.

Copy and paste the entire file here in [noparse]


[/noparse] tags. We will go from there.

OK,so this is the header.php section:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
<head profile="http://gmpg.org/xfn/11">

<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
<meta name="distribution" content="global" />
<meta name="robots" content="follow, all" />
<meta name="language" content="en" />

<title><?php wp_title(''); ?><?php if(wp_title('', false)) { echo ' :'; } ?> <?php bloginfo('name'); ?></title>
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" />
<link rel="Shortcut Icon" href="<?php echo get_settings('home'); ?>/wp-content/themes/lifestyle_20/images/favicon.ico" type="image/x-icon" />

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

<?php wp_head(); ?>

<script type="text/javascript"><!--//--><![CDATA[//><!--
sfHover = function() {
	if (!document.getElementsByTagName) return false;
	var sfEls = document.getElementById("nav").getElementsByTagName("li");

	// if you only have one main menu - delete the line below //
	var sfEls1 = document.getElementById("subnav").getElementsByTagName("li");
	//

	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\\\b"), "");
		}
	}

	// if you only have one main menu - delete the "for" loop below //
	for (var i=0; i<sfEls1.length; i++) {
		sfEls1[i].onmouseover=function() {
			this.className+=" sfhover1";
		}
		sfEls1[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover1\\\\b"), "");
		}
	}
	//

}
if (window.attachEvent) window.attachEvent("onload", sfHover);
//--><!]]></script>

</head>

<body>

<div id="wrap">

	

	

<div id="header">

	<div class="headerleft">
		<a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/spsheader.png
" alt="<?php bloginfo('name'); ?>" /></a>
	</div>
	
	<!--To define the 468x60 ad, go to your WP dashboard and go to Appearance -> Revolution Lifestyle Options and enter the ad code.-->
		
	<div class="headerright">
		<?php $ad_468 = get_option('revlifestyle_ad_468'); echo stripslashes($ad_468); ?>
	</div>

</div>

<div id="navbar">

	<div id="navbarleft">
		<ul id="nav">
			<li><a href="<?php echo get_settings('home'); ?>">Home</a></li>
			<?php wp_list_pages('title_li=&depth=4&exclude=61&sort_column=menu_order'); ?>
			
		</ul>
	</div>
	
	<div id="navbarright">
		<form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
		<input type="text" value="Search this website..." name="s" id="searchbox" onfocus="if (this.value == 'Search this website...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search this website...';}" />
		<input type="submit" id="searchbutton" value="GO" /></form>
	</div>
	
</div>

<div style="clear:both;"></div>

<div id="subnavbar">

	<ul id="subnav">
		<?php // wp_list_categories('sort_column=name&title_li=&depth=4'); ?>
	</ul>
	
</div>

<div style="clear:both;"></div>

Its not there. Its most probable that the header.php is called from another page. What page does your code from post 3 come from? Post the entie code from that page

The code from post 3 is the same one that I posted in my last post. The images name is spsheader.png.

There is something I am missing from all this. Functions are being called without anything being actually being created there.

Can you PM me the details to your file database so I can look at the files?

OK, Im guessing you mean I should login to cpanel and pm you the files there in the database? Also, I was going to say if maybe I should create another user account for my wordpress site that you could login to and check out?

Yes to the cpanel part. I’m not all too familiar with wordpress. As long as I have access to the files it should be fine. I just want to be able to see the files to make this process easier :).

It looks to me like you could hard-code your template file (and need to do it again if you upgrade it) or change your settings
(and possibly have it mess things elsewhere they’re used)

 <div class="headerleft">
        <a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/spsheader.png
" alt="<?php bloginfo('name'); ?>" /></a>
    </div> 

get_option(‘home’) returns the URL of the site, i.e. the “index” page.
bloginfo(‘template_url’) returns the path to your theme folder.
bloginfo(‘name’) returns your blog “name”.

@RyanReese; WordPress uses templates so essentially all core functions are available before the page loads.

All I simply want to do is to make the top header image link to this link ‘‘http://…’’. Seems to be far more to do than I originally thought!

I’m guessing your theme uses header.php for every page? If so and you don’t mind having every page having that link, try what kohoutek
suggested in post 7.

I’d think about this though. There is no rule that such images must link to “home”, but it is the de-facto standard and most users will expect it to be a way to get to the index page. They may be displeased if they end up on an affiliate page.

Well you see I’ve tried replacing ‘home’ with my link but when clicked it still returns to the homepage. Am I missing something?

And I can understand what your saying about the image linking to home, I might put a logo next to it in the future, but just wanna get this sorted out first!

When you change the link to what yo uwant, go online to the site, check out the source. Does it match what you entered in? If so, and it still inks wrong, give us the link to take a look at. Otherwise, you probably are changing the wrong URL somehow.