Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #617

    Call post attachments of images

    how i can call the attachments to display them after the lightbox it will be like adding another views

    #32210

    Hey,

    I don’t understand your question, can you elaborate?

    Cheers,

    James

    #32211

    (code) <?php

    $attachments = get_children( array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’) );

    foreach ( $attachments as $attachment_id => $attachment ) {

    echo ‘<ol class=”related-posts”>’;

    echo ‘ ‘ . wp_get_attachment_link( $attachment_id ) . ”;

    echo ”;

    } ?> (/code)

    There is the code im using

    And this the example page

    http://charmthemes.com/showtime-business-and-portfolio-wordpress-theme/

    i want the images to beside each other and want also to remove the lightbox from it

    #32212

    there is the code in copy paste http://pastebin.com/KCBRSMq8

    #32213

    Well i figure the problem and fix it

    One last question

    im using Related post plugin but it require custom field to show image do you know how to replace custom field to use attached images instead this will be awesome

    the code attached to this post http://pastebin.com/W3wANA5y

    You may look at the attachment code above too

    Thanks in advance

    #32214

    crazywp or anyone who can contribute I would be very thankfull!

    How Can call only the 1st attachment from the current post to display them (mostly .jpg attachments) in the current post.

    this code grabs all the attachments (images) from the blog and displays it under the 1st attachment (picture):

    <?php

    $attachments = get_children( array(‘post_parent’ => get_the_ID(), ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’) );

    foreach ( $attachments as $attachment_id => $attachment ) {

    echo ‘<div style=”float:left;margin:0px 5px 0px 0px;background:#eeeeee;border:1px solid #bbb;padding:5px;” >’;

    echo ‘ ‘ . wp_get_attachment_link( $attachment_id ) . ”;

    echo ‘</div>’;

    } ?>

    HOW CAN I EDIT THIS TO DISPLAY ONLY THE FIRST IMAGE NOT ALL IMAGES? THANK YOU VERY MUCH TO ALL IN ADVANCE :)!

    #32215

    Hey,

    try changing the code you posted above to:

    <?php
    $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => 1, 'post_mime_type' => 'image') );
    foreach ( $attachments as $attachment_id => $attachment ) {
    echo '<div style="float:left;margin:0px 5px 0px 0px;background:#eeeeee;border:1px solid #bbb;padding:5px;" >';
    echo ' ' . wp_get_attachment_link( $attachment_id ) . '';
    echo '</div>';
    } ?>

    #32216

    thank You Dude :)

    #32217

    Glad that I could help you :)

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘Call post attachments of images’ is closed to new replies.