WordPress.org

Support

Support » Plugins and Hacks » How can I show title of attachments in posts?

How can I show title of attachments in posts?

  • Hey everyone, I was wondering if i can get some help with this issue im having. I am currently using the code provided by the author(Patrik) to show attachments in posts which is

    <?php
    $args = array(
        'post_type' => 'attachment',
        'numberposts' => null,
        'post_status' => null,
        'post_parent' => $post->ID
    );
    $attachments = get_posts($args);
    if ($attachments) {
        foreach ($attachments as $attachment) {
            echo wp_get_attachment_image($attachment->ID, 'medium');
        }
    }
    ?>

    How can I show the title of the attachment? Can I show it under the attachment?

    Thanks for the help. Would appreciate any advice

    http://wordpress.org/extend/plugins/wp-user-frontend/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Maybe I’m missing something but WPUF already includes the option ‘Show attachments in the post’ that does all of this.

    TheProfessor

    Hello Professor,

    Yes it does do that but I am using the manual code so the attachments can appear in the actual post. The title of the attachments are not displayed when i insert that code

    Alter the code to display $post->post_title

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I show title of attachments in posts?’ is closed to new replies.