WordPress.org

Ready to get started?Download WordPress

Forums

WP User Frontend
How can I show title of attachments in posts? (4 posts)

  1. steveone86
    Member
    Posted 1 year ago #

    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/

  2. professor99
    Member
    Posted 1 year ago #

    Maybe I'm missing something but WPUF already includes the option 'Show attachments in the post' that does all of this.

    TheProfessor

  3. steveone86
    Member
    Posted 1 year ago #

    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

  4. professor99
    Member
    Posted 1 year ago #

    Alter the code to display $post->post_title

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.