Print WordPress Gallery Using gallery_shortcode Function Rather Than do_shortcode

Most Developers, designers and WordPress users use the native gallery shortcode to display their gallery.

gallery

You can also use the shortcode in a custom function like this:

add_action( 'loop_start', 'gallery_do_shortcode' );
function gallery_do_shortcode() {
echo do_shortcode('[gallery-shortcode-demo]');
}

The only problem is, shortcodes are not the most efficient way to execute a function or print your gallery as you can read more about here.

Another solution you can choose from if you want to display your gallery outside the content area is to use the gallery_shortcode callback function in your child themes functions file like this:


Comments

One response to “Print WordPress Gallery Using gallery_shortcode Function Rather Than do_shortcode”

  1. […] Print WordPress Gallery Callback Function Rather Than do_shortcode […]

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.