[Resolved] Setting up an image gallery for a custom post type
This thread is resolved. Here is a description of the problem and solution.
Problem:
How to create a slider from images stored as custom fields on a post?
Solution:
Since Types 3 it is possible to achieve this using Views' built-in slider functionality (which is intended to rotate between slides from different posts, not the same post).
- set up a repeating field group and include an image field (and any other fields you may need such as caption)
- add images and captions to your posts
- create a View which in the Content Selection will query the repeating field group
- add a Query Filter to specify that the repeating field group belongs to the post where this View is being displayed
- design your Loop Output according to the documentation for creating sliders
- insert this View into the template where you display your posts.
Tell us what you are trying to do? I'm trying to create an image gallery on a custom post. My approach is to create a custom field for the custom post, but there is no field type for an image gallery as far as I can tell. (Is there another, or better, way?)
What is the link to your site? I am uploading a link to a screenshot of the design. The slideshow is toward the top of the page, beneath the page title.
You use a repetitive image field on your posts (so that you can add multiple image fields to the same post), and then in your template loop over these fields using the wpv-for-each shortcode to output them in the markup format required by your chosen slider library (flexslider in the example).
Types 3.0 introduced repeating field groups, so that you could have both an image and a caption field grouped together and then add as many of these as you need to an individual post. Under the hood this works by creating a new post for each repetition that acts as a container for the group of fields.
This is exactly what you need to use the existing Views slider functionality as outlined in the above document, where your slider will transition between the posts that act as containers for the image and caption fields.
So
- set up a repeating field group and include an image field (and any other fields you may need such as caption)
- add images and captions to your posts
- create a View which in the Content Selection will query the repeating field group
- add a Query Filter to specify that the repeating field group belongs to the post where this View is being displayed
- design your Loop Output according to the documentation for creating sliders
- insert this View into the template where you display your posts.
Hello.
I followed the step as you wrote but something goes wrong.
I have post type named charter
I have a lot of custom field divided in groups that I use in content template for single charter.
I designed content template with beaver builder
I created a new custom field only for charter image with repeaiting field.
I created a view as you wrote but depending from query filter or are showing all the image in my site or nothing are showing.
I can't understand where is the problem