Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #276485

    Hello, there is only title tag for Featured image in single post. Is it possible to set alt tag same as title tag?

    Please help me, it is already 2 days I’m trying to set alt tags without any success.

    Here is the link to my single post.

    http://animalpictures.gallery/jiddu-krishnamurti-173/

    Thank You
    George

    #276490

    Hey georgedz!

    You can set Alt Text on right side of featured image uploading screen as shown here – http://i.imgur.com/6XaXxb0.png

    Cheers!
    Yigit

    #276502

    Hi Yigit, thanks for your answer. The problem is that I’m uploading a lot of pictures and I can’t go through each image. I just want to set alt text same as image name or post title.

    I know that this is beyond free support but please please help :)

    George

    #276535

    Hi George,

    Try adding this at the very end of your theme functions.php file:

    function add_custom_script(){
    ?>
    <script>
    jQuery(window).load(function(){
    	   jQuery("img").attr("alt", jQuery("title").text());    
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Regards,
    Josue

    #276606

    Thanks Josue, I have added the script but it seems that nothing has changed : (

    Even when I add alt text through attachment details as shown here http://i.imgur.com/6XaXxb0.png
    For example I have added alt text for this post and when I check the source code there is no alt tag, only title
    a rel=”lightbox[grouped]” href=”http://animalpictures.gallery/wp-content/uploads/Lao-Tzu.png” title=”test test test”

    Is there any other option you can think of?

    Many thanks guys
    George

    • This reply was modified 4 months, 1 week ago by  georgedz.
    #276613

    Seems to be working for me (the value that’s getting applied to the Alt tag is the one of the Title tag:

    Note that this is getting applied to the singular view:

    http://animalpictures.gallery/grumpy-cat-no-levelupstudios-aaronwood-noyoucant-ladies-750/

    Best regards,
    Josue

    #276630

    I’m now looking at the source code and alt tag is empy, is there an alt tag for you?
    Here is the screenshot of the source code, am I doing something wrong? : )
    Screen shot

    Thank you Josue,
    George

    #276663

    Yes, you won’t see it there because it’s being added via JavaScript after the page is loaded.

    Cheers!
    Josue

    #276795

    Oops, it is because of SEO I want to set alt tags :) Thank you Josue for your time, i really appreciate your help.
    Is there anything alse I can do?
    I was searching something to edit in single.php without any success. I guess i need to add alt=”<?php the_title(); ?>”
    somewhere as suggested in a post below.

    http://wordpress.stackexchange.com/questions/57968/add-post-title-as-alt-tag-for-featured-image

    But can’t make it work

    Thanks
    George

    #276889

    Hey!

    We use the get_the_post_thumbnail() function ( http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail ) in wp-content/themes/enfold/includes/loop-index.php to fetch the featured image. This function adds the alt text automatically if the “Alternative text” field on the attachment page isn’t empty: http://www.clipular.com/c/6364087445356544.png?k=h684IvqFw7AVyUGNT6s1kYbNZ-s

    Best regards,
    Peter

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.