Welcome to the IMTalk - Internet Marketing & SEO Forum.
  • Login:
+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    burgers is offline IM & SEO Whisperer burgers is on a distinguished road
    Join Date
    Jun 2011
    Posts
    77
    Thanks Given
    7
    Thanked 16 Times in 12 Posts

    Any PHP experts? A function to change header based on current URL?

    I want to write a function in Wordpress to change the img alt tags for the header image for each wordpress page based on the URL and create its own URL image link, so that each page has the same looking header image, but it will show different alt tags and image URL location.

    I'm really rusty with C#, know basic html and haven't learned php, but I think I know how it should be done.

    Function has to compare current page URL, maybe using the_permalink() ... to a list of permalinks that I'm using ... maybe in an array?

    if the_permalink() = array

    array=
    permalink1 => <img src=imageURL1 alt=kw1>
    permalink2 => <img src=imageURL2 alt=kw2>
    permalink3 => <img src=imageURL3 alt=kw3>

    display=array


    It should be easy coding right? If anyone proficient at PHP can chime in, much appreciated!

    Cheers!

  2. #2
    adbox is offline IM & SEO Whisperer adbox is on a distinguished road
    Join Date
    Nov 2011
    Posts
    41
    Thanks Given
    1
    Thanked 8 Times in 7 Posts
    Nice! Let me have it when your done maybe for helping.

    Well the header is outside of the loop so we have to use some php to find out the current pages title

    PHP Code:
    $current_url "h.t.t.p://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]."";
    $post_id url_to_postid($current_url);
    get_post($post_id$post);
    $title $post->post_title
    then we would want to find our image html code and echo $title into alt.


 

Similar Threads

  1. Dynamic Image Header Optimization
    By Hajoless in forum Web Hosting, Servers & Domains
    Replies: 0
    Last Post: 08-09-2011, 07:19 AM
  2. Replies: 0
    Last Post: 01-11-2011, 01:52 PM
  3. Replies: 0
    Last Post: 01-11-2011, 01:51 PM
  4. Learning Search Engine Optimization From the Experts
    By Nemanja in forum General SEO Talk
    Replies: 1
    Last Post: 10-07-2010, 11:38 PM
  5. WTS : Header / Logo Designing Services
    By pass1meister in forum Services
    Replies: 0
    Last Post: 09-02-2010, 08:42 PM

Posting Permissions

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