Can I automatically add a gallery to articles?

­

Leveraging the facts that:

  • JIG can detect and show images attached to a post automatically...
  • You can create a PHP template tag and place it anywhere in the theme...

It's clear that if you use plenty of pictures throughout your posts, an automatic gallery at the beginning or end of articles is a good idea.

Add a gallery of attached images automatically
  1. Locate the file of your theme that's for showing single posts, products etc. Depending on your theme and custom post type, it may be different but it's usually the /wp-content/themes/Avada/single.php file. It's recommended to use child themes though.
  2. Find the line that contains:
  3. Add this where you need the gallery:
  4. Some posts might not have images, so hide the JIG error message: "There are no photos with those IDs or post X does not have any attached images!" Add this to JIG settings > General tab > Custom CSS setting:
Pro tip: Create a related posts gallery at the bottom of your articles
It works by finding posts that are at least in one category of current one. You can replace the word category with your custom taxonomy or use other shortcode attributes. Instead of step 3 above, your code should be based on this:
This FAQ entry was posted in Advanced use on July 4, 2015