WordPress.org

Ready to get started?Download WordPress

Forums

Image Alt Text possible with this? (6 posts)

  1. Jay
    Member
    Posted 2 years ago #

    Using a custom field to generate image. Need to pull the alt text as well. Here is what I'm using.

    <?php  if((get_post_meta($post->ID, "image", true))) { ?>
    <img src='/images/<?php echo get_post_meta($post->ID, "image", true); ?>' />
     <?php } ?>
  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    add another custom field for the 'alt' text?

  3. Jay
    Member
    Posted 2 years ago #

    I will try that. Thanks!

  4. Jay
    Member
    Posted 2 years ago #

    I tried this, but it leaves me with a blank "alt". I read this is where word press stores _wp_attachment_image_alt is where it's alt text for images.

    <img alt='<?php get_post_meta($post->ID, '_wp_attachment_image_alt', true); ?>

  5. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    you are not using an attachment image, you are using a image name in you first custom field - how is the code to know the connection?

    i meant you need to crate a new custom field and type the alt text into it, the same way you enter the image name into the first custom field.

  6. Jay
    Member
    Posted 2 years ago #

    I completely overlooked the connection part. haha maybe its time for a break. I understood you, I was trying to prevent an extra custom field. Thanks! :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.