How to insert multiple images in a single post inside a CPT?

-1

I created a Custom Post Type to publish multiple images together.

---> > > title > > image highlighted / default ---
  ----> text

asked by anonymous 18.08.2016 / 18:14

1 answer

0

Zkk,

The option considering the use of plugins is quite simple and easy to implement. There are numerous plugin alternatives available that offer a specific field type with the feature being repeatable, which is exactly what you are looking for.

I will present some steps that intend to cover the generic steps, regardless of the plugin chosen:

1) Choose a plugin that works with custom fields and has the repeatable fields (or loop ) functionality. Search the WordPress plugins directory, or use this comparative list that already lists options.

  

Important: Make a choice based on those that provide repeatable fields - which is a feature pointed to in the table.

2) After installing the plugin, the next step is to create a custom field (or a group of fields, depending on the plugin you choose) of the IMAGE type that is repeatable (or a repeatable group that has a field of image that can therefore be repeated).

3) Define in the filters of this field / group that they should only be available in your specific CPT.

4) Now do the implementation in your code. Each plugin uses a different function to return the registered data with the custom fields, so see the documentation of the alternative you chose. In php , you will probably receive an array of all images, and then just run a foreach to print each of the images available.

Good luck!

  

Note: I chose not to indicate a specific plugin to make this   commercial interests, since many of them are   available in free or paid versions.

    
25.08.2016 / 00:04