• Resolved salave

    (@salave)


    Please help me to add image alt code additional on this code presented on my theme.

    <a class=”bs-author-pic mb-3″ href=”<?php echo esc_url(get_author_posts_url( get_the_author_meta( ‘ID’ ) ));?>”><?php echo get_avatar( get_the_author_meta( ‘ID’) , 150); ?></a>

Viewing 7 replies - 1 through 7 (of 7 total)
  • Look at the documentation for the get_avatar() function. Alt text is the 4th argument.

    Thread Starter salave

    (@salave)

    Thank you for replying. My problem is that I don’t know anything about php; I’m used to html. If I add anything, the brackets will result in a mistake. Would be helpful if you show to me a result i test

    <?php echo get_avatar( get_the_author_meta( ‘ID’) , 150, '', 'Alt text goes here'); ?>
    Thread Starter salave

    (@salave)

    I did add <?php echo get_avatar( get_the_author_meta( ‘ID’) , 150, ”, ‘Profile image’); ?>

    And output source code is missing =” “

    Screenshot https://i.postimg.cc/tRNdghGM/Screenshot-20230526-124452.png

    Moderator bcworkz

    (@bcworkz)

    If you used catacaustic’s code exactly as posted, it contains a syntax error, wrong kind of quotes around ‘ID’. The following works for me within “The Loop” context:
    <?php echo get_avatar( get_the_author_meta('ID') , 150, '', 'Profile image'); ?>

    Thread Starter salave

    (@salave)

    Hi after using catacaustic’s code, it was show only alt (word) and missing =” ” and the page was inaccessible due to syntax error, thanks to bcworkz for noticing the problem.

    Now after using bcworkz code, we have got a full alt=” ” but as you can see the profile image text is missing in the quote.

    -1-150×150.jpeg” class=”” alt=”” decoding=”async” loading=”lazy”

    Thread Starter salave

    (@salave)

    Finally it has worked! Thanks for helping https://i.postimg.cc/0N40vFDR/Screenshot-20230527-194300.png

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to add image alt on this code’ is closed to new replies.