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


Nesting a page with ACF Gallery Field

  • 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;
  • 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!

  • 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)

The topic ‘Nesting a page with ACF Gallery Field’ is closed to new replies.