WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] How to display images separate from content?

[Resolved] How to display images separate from content?

  • Andrew

    @ndrwglrzayahoocom

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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()

    Andrew

    @ndrwglrzayahoocom

    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

    Andrew

    @ndrwglrzayahoocom

    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] How to display images separate from content?’ is closed to new replies.
Skip to toolbar