Home › Forums › Add-ons › Gallery Field › Creating separate page for ACF-Gallery field
Hello!
I have a Custom Post Type, which has an ACF Gallery Field. I want to create a separate gallery page for this Custom Post Type, where just the Images from my Gallery Field appears.
I don’t know how to create a link to this page. I read the template hierarchy codex but did not find what i’m looking for.
Thanks!
Kolos
i dont understand where your problem is:
what are you using? what code did you have? what are you trying to do?
Let’s say, i have a CPT: ‘Performance’, with a few Custom Fields (also an ACF-Gallery field). I have a single-performance.php, where you can see all the things about a performance (also the element of the ACF-Gallery field).
I made a page-gallery.php. In the admin site of this, there is an ACF-Relationship Field (with multiple values), where you can choose performances.
I wrote a code in the page-gallery.php, which displays the Featured Image and the Title of the Performances, which are set in the ACF-Relationship field. Now, the Titles and Images are links to the single-performance.php. My goal is, if they click on a Title/Image, then they see a page, where only the Images of the Performance appears, and not the hole single-performance.php.
But i have no idea how to do that. I need like one more single-performance.php, which appears different as the first one. I can write the content of it, but i don’t know how to name it, and how to create a link to it.
just to get sure:
you have a working single-performance.php, that print out everything you need.
you have a working page-gallery.php with featured image and title that link for now to single-performance.php?
and you wish a link to single-performance.php that only shows the gallery?
if yes, i think this will be the easiest way to solve that would be:
inside page-gallery.php something like that instead of permalink only
add_query_arg( 'gallery_only', 'yes', get_permalink() );
inside your plugin or functions.php add it to the public query variables
function add_custom_query_var( $vars ){
$vars[] = "gallery_only";
return $vars;
}
add_filter( 'query_vars', 'add_custom_query_var' );
inside single-performance.php get value that you pass when it come from page-gallery.php
$my_gallery_only = get_query_var( 'gallery_only' );
use after that if ($my_gallery_only == 'yes')
to switch between your normal-all and gallery-only view
hope that this is what you need and that it works for you
The topic ‘Creating separate page for ACF-Gallery field’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.