• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

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:

Register for full access

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.