1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Site-wide Image SEO

Discussion in 'White Hat SEO' started by reinie, Jan 23, 2011.

Thread Status:
Not open for further replies.
  1. reinie

    reinie Elite Member

    Joined:
    Jan 16, 2009
    Messages:
    1,574
    Likes Received:
    1,040
    Hi guys.
    Ok so I want to use the following code on my blog:

    <h3><a href="<?php the_title(); ?>.jpg" rel="lightbox"><img src="imagefolder/<?php the_title(); ?>.jpg" alt="<?php the_title(); ?>" align="left" /></a><</h3>

    I will insert it in my template at the beginning of every post, and the result is the same image being displayed eveytime a post is made, except it will change the alt tag to be the same as the title of the page, and link to the image on stand alone.

    Now the only part I do not know, is how to take the default image, say for instance picture.jpeg, and have wordpress copy and rename it everytime a new post is made so that i have uniqqe pictures accross the board.

    Can anyone please assist me with this, or is there a better way to do this?
    Thanks
     
  2. f0rked

    f0rked Registered Member

    Joined:
    Jan 25, 2009
    Messages:
    71
    Likes Received:
    64
    Code:
    <?php
    $title = get_the_title();
    $loweredTitle = strtolower($title);
    $post_image = str_replace(" ", "_", $loweredTitle);
    $check = "imagefolder/".$post_image.'.jpg';
    if (file_exists($check)){
    }else{
    copy('imagefolder/offer.jpg', 'imagefolder/'.$post_image.'.jpg');
    }
    ?>
    <h3><a href="imagefolder/<?php echo $post_image.'.jpg'; ?>" rel="lightbox"><img src="imagefolder/<?php echo $post_image.'.jpg'; ?>" alt="<?php echo the_title(); ?>" align="left" /></a></h3>
     
    • Thanks Thanks x 2
  3. reinie

    reinie Elite Member

    Joined:
    Jan 16, 2009
    Messages:
    1,574
    Likes Received:
    1,040
    Your The man, works perfectly...
    thanks and rep given...

    I think this should do wonders for seo purposes...
     
  4. reinie

    reinie Elite Member

    Joined:
    Jan 16, 2009
    Messages:
    1,574
    Likes Received:
    1,040
    and ofcourse adding the title tag...
     
Thread Status:
Not open for further replies.