SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,213
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    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:

    Code:
    <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.

  3. #3
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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">

    <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>

    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.

  4. #4
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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 .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  5. #5
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  6. #6
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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");
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  7. #7
    Mazel tov! bronze trophy kohoutek's Avatar
    Join Date
    Aug 2004
    Location
    Hamburg, Germany
    Posts
    4,248
    Mentioned
    30 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Kaplan_T4 View Post
    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.
    You need to change the portion marked in red.

    Code:
    <a href="<?php echo get_option('home'); ?>/"><img src="<?php bloginfo('template_url'); ?>/images/spsheader.png
    " alt="<?php bloginfo('name'); ?>" /></a>
    Maleika E. A. | Rockatee | Twitter | Dribbble



  8. #8
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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 [code][/code] tags. We will go from there.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  10. #10
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK,so this is the header.php section:

    PHP Code:
    <!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>
    Last edited by Mittineague; Mar 31, 2012 at 20:29. Reason: reformatting bbcode tags

  11. #11
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  12. #12
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code from post 3 is the same one that I posted in my last post. The images name is spsheader.png.

  13. #13
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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?
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  14. #14
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  15. #15
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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 .
    Always looking for web design/development work.
    http://www.CodeFundamentals.com

  16. #16
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,191
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    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)
    PHP Code:
     <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.

  17. #17
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!
    Last edited by Mittineague; Mar 31, 2012 at 21:19. Reason: removing aff url

  18. #18
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,191
    Mentioned
    191 Post(s)
    Tagged
    2 Thread(s)
    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.

  19. #19
    SitePoint Member
    Join Date
    Mar 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  20. #20
    billycundiff{float:left;} silver trophybronze trophy RyanReese's Avatar
    Join Date
    Oct 2008
    Location
    Whiteford, Maryland, United States
    Posts
    13,624
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    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.
    Always looking for web design/development work.
    http://www.CodeFundamentals.com


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •