Forums

[resolved] Strange view of image alt tags (4 posts)

  1. Fotosons
    Member
    Posted 1 year ago #

    Hi,

    I'm using the_excerpt to fill the alt tags of my images in wordpress. But when I look the code the result is something like that:

    title="Image title" alt="<p>Image tag</p>"/></a>

    Anybody knows why the alt section shows between paragraphs? The code of the theme is:

    <a href="<?php the_permalink() ?>"><img src="<?php echo $thumbnail_value; ?>" title="<?php the_title(); ?>" alt="<?php the_excerpt(); ?>"/></a>

    Help me with that please, thanks!

  2. zoonini
    help me help you
    Posted 1 year ago #

    the_excerpt automatically adds opening and closing paragraph tags around the text contained within it. That particular function isn't meant for ALT tags, it's meant to generate a paragraph of text summarizing a post, hence the <p> tags.

    http://codex.wordpress.org/Function_Reference/the_excerpt

  3. alchymyth
    The Sweeper
    Posted 1 year ago #

    http://codex.wordpress.org/Function_Reference/get_the_excerpt

    <a href="<?php the_permalink() ?>"><img src="<?php echo $thumbnail_value; ?>" title="<?php the_title(); ?>" alt="<?php echo get_the_excerpt(); ?>"/></a>

  4. Fotosons
    Member
    Posted 1 year ago #

    Hi Alchymyth!

    Resolved!!! Thanks a lot!!!

Topic Closed

This topic has been closed to new replies.

About this Topic