Support » Plugins » [Plugin: File Un-Attach] loop.php gallery shortcode

  • Ran into a wall with file un-attach . . . get_children will fail to see all attachments depending on which template its on. single.php is fine while loop.php is not.

    In the function below I’m asking for all attached jpegs ordered by menu_order ID, only the first one is selected, and inserted it into the_content via apply filters.

    Attached to the post are two images:
    in position one is an image that was previously attached to another post
    in position two is an image which is ONLY attached to this post.

    The result is that the image presented will change depending on where I view it. From single.php template I will see the image in position one. When viewing from loop.php on a paginated page of posts – I will see the image in position two!

    In other tests the result is that all attachments where a connection has been previously made to another post – will fail in the loop.php context.

    Anyone know what’s going on?
    Many thanks for your help and experience.

    Here is the function – nothing special:

    function tr_get_post_img($size='thumbnail') {
    	global $post;
    	$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image/jpg', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    	if ($photos) {
    		$image_src = wp_get_attachment_image_src($photo->ID, $size);
    		$tr_post_thumb = '<img src="' . $image_src[0] . '" class="thumbnail" alt="' . get_the_title($photo->ID) . '" />';
    		echo apply_filters('the_content', $tr_get_post_img );
    	return false;}

Viewing 1 replies (of 1 total)
  • mmmm… not sure I will take a look a it to see what is the problem, in the mean time you can use the function provided by the plugin “fun_get_attachments()”

    view the documentation for more information .

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: File Un-Attach] loop.php gallery shortcode’ is closed to new replies.