WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sow all attachements, without links (4 posts)

  1. Beee
    Member
    Posted 3 years ago #

    As stated on http://codex.wordpress.org/Function_Reference/get_posts#Show_attachments_for_the_current_post

    I use this code

    $args = array( 'post_type' => 'attachment', 'numberposts' => 3, 'post_status' => null, 'post_parent' => $post->ID );
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ( $attachments as $attachment ) {
    		the_attachment_link( $attachment->ID , true );
    	}
    }

    the_attachment_link( $attachment->ID , true );
    links to the image, but I don't want it to link to anything.

    is used on http://www.aaiko.com/top-pelan/
    (or any single post in http://www.aaiko.com/collection/)

  2. 123milliseconds
    Member
    Posted 3 years ago #

    Returns an HTML image element representing an attachment file, if there is any, otherwise an empty string.

    http://codex.wordpress.org/Function_Reference/wp_get_attachment_image

  3. Beee
    Member
    Posted 3 years ago #

    tried it but can't get it to work...

  4. Beee
    Member
    Posted 3 years ago #

    and suddenly I had it...

    $args = array( 'post_type' => 'attachment', 'numberposts' => 3, 'post_status' => null, 'post_parent' => $post->ID );
    	$attachments = get_posts($args);
    	if ($attachments) {
    		foreach ( $attachments as $attachment ) {
    			echo wp_get_attachment_image($attachment->ID, thumbnail, true);
    		}
    	}

Topic Closed

This topic has been closed to new replies.

About this Topic