Home Forums Add-ons Gallery Field Nesting a page with ACF Gallery Field


Nesting a page with ACF Gallery Field

    • yari

    • September 10, 2013 at 8:11 am

    I created a page in WordPress that contains an ACF Gallery. My intent is to pull that page into various parts of my template (ie. on the sidebar on one page, on the bottom on another). Because technically the gallery isn’t part of the content editor, the code I usually use is not pulling in the gallery images.

    Is there a way to call the gallery content? Here is the code I’ve used in the past, I welcome any edits (or other suggestions) to pull in my images!

    $my_id = 1276;
    $post_id_1276 = get_post($my_id);
    $content = $post_id_1276->post_content;
    echo $content;
    • Elliot

    • September 10, 2013 at 10:59 am

    Hi @yari

    In a similar way, you can target a specific page’s custom field data using a second parameter in either the get_field() or the_field() functions.

    You can read more in this article:

    That will get your data loaded, rending the data is up to you

    Good luck!

    • yari

    • September 10, 2013 at 1:23 pm

    Thanks @elliot, I think the piece that I was missing is the fact that I could add a comma and the page number to specify the page. I used some of the other code and adjusted with this extra bit. Very helpful!

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.