WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to display images separate from content? (4 posts)

  1. Andrew
    Member
    Posted 2 years ago #

    How can I display a posts' images separate from the_content? i.e. in another table cell.

    I've been trying get_image_attachment etc... in my theme but it hasn't been working for me.

    Please help.

    Thank you,

    Andrew

  2. jonradio
    Member
    Posted 2 years ago #

    The [gallery] shortcode is the most common approach.

    But I'm guessing that you probably want something like this for a template:

    $images = get_children( array(
    						'post_parent' => $post->ID,
    						'post_status' => 'inherit',
    						'post_type' => 'attachment',
    						'post_mime_type' => 'image',
    						'order' => 'ASC',
    						'orderby' => 'menu_order ID'
    						)
    					);

    Then use foreach to cycle through the images with wp_get_attachment_image()

  3. Andrew
    Member
    Posted 1 year ago #

    Okay, can you help with the foreach part please?

    Perhaps help me with a code that I can get to work on my page please?

    Thank you,

    Andrew

  4. Andrew
    Member
    Posted 1 year ago #

    Okay, I got it to work, the problem was that on my local server there were no local attachments, so they weren't showing.

    Thank you,

    Andrew

Topic Closed

This topic has been closed to new replies.

About this Topic