• pet3r

    (@sboerupgmailcom)


    I have a script on my site that displays images that are attached to the page. Currently it is only displaying photo attachments on that page only.

    Is there any way to call attachments from other pages via page IDs?

Viewing 2 replies - 1 through 2 (of 2 total)
  • You probably have to create a function in your functions.php file using

    https://codex.www.ads-software.com/Function_Reference/has_post_thumbnail

    it accepts the page ID. You can make your function as shortcode

    https://codex.www.ads-software.com/Shortcode_API

    so it can be inserted into your posts.

    I haven’t seen a plugin for this yet (although it might exist).

    Thread Starter pet3r

    (@sboerupgmailcom)

    I currently have this array on a page:

    <?php $args = array(
    ‘orderby’ => ‘menu_order’,
    ‘order’ => ‘ASC’,
    ‘post_type’ => ‘attachment’,
    ‘post_parent’ => $page_id = 1339,
    ‘post_mime_type’ => ‘image’,
    ‘post_status’ => null,
    ‘numberposts’ => $imageNumber
    );
    $attachments = get_posts($args);

    $args2 = array(
    ‘post_type’ => ‘attachment’,
    ‘post_parent’ => $page_id = 1339,
    ‘post_mime_type’ => ‘image’,
    ‘post_status’ => null,
    ‘numberposts’ => -1
    );
    $attachments2 = get_posts($args2);
    ?>

    I manually entered the page_id and it pulls the attachments from a different page. I would love to be able to have it pull attachments from multiple pages. The “post_parent” looks like the only line of concern, I just don’t know how the specifics for multiple IDs there

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Calling $attachments from multiple pages’ is closed to new replies.