• Hi there,

    I want to add images from a specific post. I#m using the following code.

    function myGalleryShortcode() {
    	$attachments = get_children( array('post_parent' => null, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => 'rand', 'numberposts' => 6) );
    
    	if ( empty($attachments)) return '';
    
    	$output = "<div id='bildergalerie' class='gallery'><h2>Bildergallerie</h2>";
    
    	foreach ($attachments as $id => $attachment ) {
    			   $output .= '<a href="' .get_attachment_link($id). '">' .wp_get_attachment_image($id, 'thumbnail', false) . '</a>';
    			   }
    
    			   $output .= "</div>";
    
    			   return $output;
    	}

    It shows me some pictures, but not from one specific page.
    I think I have to change it in something like:
    ‘post_parent’ => singleID(123)

    But how do I have to write it correctly to get the images from post number 123? Or am I completely wrong?

    Thanks for your help.

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Add images from a specific post’ is closed to new replies.