So, I do have a function to get related posts in my functions.php for WordPress. It is working fine BUT the images do not have an alt tag.

Part of my code:

 $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';

                $related .= '<li><a href="' . get_permalink() . '" rel="bookmark" title="' . get_the_title() . '">' . $img . '<p>' . get_the_title() . '</p></a></li>';

Any idea how I can tell WordPress to add the title as alt tag, like it is with the title tag inside the link?

thanks

Read more here: WordPress, related Posts how to add ALT tag to img?


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: