Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WordPress: Display 3 Random Images Attached to a Different Page

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #32241
    TheDoc
    Member

    Question is in the title! For the life of me I cannot figure this out.

    On a page (not post) I want to include three thumbnails from a gallery that is on another page (not post), but I can’t see how to do it.

    I feel like I’m sort of on the right path with this, but I really have no idea where to begin.

    My only gripe with WordPress, their silly media/asset management.

    #52272
    enfotoad
    Member

    Try the following link:

    http://www.rlmseo.com/blog/get-images-attached-to-post/

    Though it has post to post/page you can edit the code so it references from another pageID instead of a postID.

    Hope that helps!

    #52247
    TheDoc
    Member

    Actually got it solved with this:

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

    Love figuring things out!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.