WordPress.org

Ready to get started?Download WordPress

Forums

How to add an image caption / alt text or description with php? (1 post)

  1. PODxt
    Member
    Posted 3 months ago #

    Hi, I'm trying to add captions, alt text and description on images (actually a slideshow). I can add the image title with:

    <h1><?php the_title(); ?></h1>

    But how to do so for the captions, alt text and description fields?
    Here's a relevant sample of the rest of the code if it can help:

    <div class="slide">
    
        <?php if ( get_post_meta( $post->ID, "slide_url_value", $single = true ) != "" ): ?>
        <a
        href="<?php echo get_post_meta( $post->ID, " slide_url_value ", $single = true ); ?>"
        title="<?php the_title(); ?>">
            <?php the_post_thumbnail( 'featured-slide', array( 'title' => get_the_title() ) ); ?>
        </a>
    
        <?php else: ?>
        <?php the_post_thumbnail( 'featured-slide', array( 'title'=>get_the_title() ) ); ?>
        <?php endif; ?>
            <h1><?php the_title(); ?></h1>
    
    </div>

    Maybe using <?php the_field(''); ?> with id slugs??
    Thanks

Reply

You must log in to post.

About this Topic