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

  1. PODxt
    Posted 2 years 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 ) != "" ): ?>
        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() ) ); ?>
        <?php else: ?>
        <?php the_post_thumbnail( 'featured-slide', array( 'title'=>get_the_title() ) ); ?>
        <?php endif; ?>
            <h1><?php the_title(); ?></h1>

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

Topic Closed

This topic has been closed to new replies.

About this Topic