Title: Using shortcode in post format template
Last modified: August 20, 2016

---

# Using shortcode in post format template

 *  Resolved [adaldesign](https://wordpress.org/support/users/adaldesign/)
 * (@adaldesign)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/using-shortcode-in-post-format-template/)
 * What I like about this plugin is that it uses the native WP [gallery] functionality:
   easy UI for users.
 * However, in my attempt to further simplify the UI, I am using post-formats. In
   my content-gallery.php post-format template I am using php to auto-insert the
   shortcode:
 * `<?php echo do_shortcode( '[gallery link="file" columns="3"]' ); ?>`
 * The issue is that your plugin uses PHP to add necessary markup to the `<a>` tag
   by parsing the_content, rather than applying to all [gallery] shortcodes. So 
   my thumbnail links aren’t launching the Galleria.
 * Can you provide an update or filter that would add the necessary markup to all
   occurrences of the shortcode, regardless of it being found in the_content?
 * [http://wordpress.org/extend/plugins/fullscreen-galleria/](http://wordpress.org/extend/plugins/fullscreen-galleria/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [pdamsten](https://wordpress.org/support/users/pdamsten/)
 * (@pdamsten)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-in-post-format-template/#post-3156278)
 * After quick search I could not find any other filter than ‘the_content’ that 
   could be used to modify links. One solution could be to use plugin that adds 
   gallery to certain posts and is run before fullscreen-galleria (priority 99).
 *  Thread Starter [adaldesign](https://wordpress.org/support/users/adaldesign/)
 * (@adaldesign)
 * [13 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-in-post-format-template/#post-3156312)
 * Thanks for the reply pdamsten.
 * I ended up integrating Galleria into the theme itself:
 * **1- Loading the CSS and Scripts in header.php**
 *     ```
       <link rel='stylesheet' id='galleria-fs-css'  href='<?php echo get_stylesheet_directory_uri(); ?>/galleria/themes/twelve/galleria.twelve.css' type='text/css' media='all' />
       <script type='text/javascript' src='<?php echo get_stylesheet_directory_uri(); ?>/galleria/galleria-1.2.8.min.js'></script>
       <script type='text/javascript' src='<?php echo get_stylesheet_directory_uri(); ?>/galleria/themes/twelve/galleria.twelve.min.js'></script>
       ```
   
 * **2- Launching the Galleria script in header.php**
    `<script type="text/javascript"
   > Galleria.run('#galleria', { height: 0.75 }); </script>`
 * **3- Modifying the `[gallery]` shortcode output in functions.php**
 *     ```
       /**
        * Modifies WP Gallery functionality to use Galleria
        * AdalDesign.com
        */
   
       //Deactivate WordPress Gallery function
   
       remove_shortcode('gallery', 'gallery_shortcode');
       //activate own function
       add_shortcode('gallery', 'ad_gallery_shortcode');
       //the own renamed function
       function ad_gallery_shortcode($attr) {
       	global $post, $wp_locale;
   
       	static $instance = 0;
       	$instance++;
   
       	// Allow plugins/themes to override the default gallery template.
       	 $output = apply_filters('post_gallery', '', $attr);
       	 if ( $output != '' )
       	return $output;
   
       	// We're trusting author input, so let's at least make sure it looks like a valid orderby statement
       	if ( isset( $attr['orderby'] ) ) {
       		$attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
       		if ( !$attr['orderby'] )
       			unset( $attr['orderby'] );
       	}
   
       	extract(shortcode_atts(array(
       		'order'      => 'ASC',
       		'orderby'    => 'menu_order ID',
       		'id'         => $post->ID,
       		'itemtag'    => 'dl',
       		'icontag'    => 'dt',
       		'captiontag' => 'dd',
       		'columns'    => 3,
       		'size'       => 'thumbnail',
       		'include'    => '',
       		'exclude'    => ''
       	), $attr));
   
       	$id = intval($id);
       	if ( 'RAND' == $order )
       		$orderby = 'none';
   
       	if ( !empty($include) ) {
       		$include = preg_replace( '/[^0-9,]+/', '', $include );
       		$_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
   
       		$attachments = array();
       		foreach ( $_attachments as $key => $val ) {
       			$attachments[$val->ID] = $_attachments[$key];
       		}
       	} elseif ( !empty($exclude) ) {
       		$exclude = preg_replace( '/[^0-9,]+/', '', $exclude );
       		$attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
       	} else {
       		$attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) );
       	}
   
       	if ( empty($attachments) )
       		return '';
   
       	if ( is_feed() ) {
       		$output = "\n";
       		foreach ( $attachments as $att_id => $attachment )
       			$output .= wp_get_attachment_link($att_id, $size, true) . "\n";
       		return $output;
       	}
   
       	$itemtag = tag_escape($itemtag);
       	$captiontag = tag_escape($captiontag);
       	$columns = intval($columns);
       	$float = is_rtl() ? 'right' : 'left';
   
        $output = apply_filters('gallery_style', '<div id="galleria">');
   
       $i = 0;
       	foreach ( $attachments as $id => $attachment ) {
       		$image_title = 		$attachment->post_title;
       		$description = 		$attachment->post_content;
       		$galleryImgURL = 	wp_get_attachment_image_src( $id, 'medium', false );
       		$galleryImgURL = 	$galleryImgURL[0];
       		$galleryThumb = 	wp_get_attachment_image_src( $id, 'thumbnail', false);
       		$galleryThumb = 	$galleryThumb[0];
       		$fullscreenURL = 	wp_get_attachment_image_src( $id, 'large', false);
       		$fullscreenURL = 	$fullscreenURL[0];
   
       		$output .= '<a href="' . $galleryImgURL. '"><img src="' . $galleryThumb . '" data-big="' . $fullscreenURL . '" data-title="' . $image_title . '" data-description="' . $description . '"></a>';
       	}
   
       	$output .= '</div>';
       	return $output;
   
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Using shortcode in post format template’ is closed to new replies.

 * ![](https://ps.w.org/fullscreen-galleria/assets/icon-256x256.png?rev=1003688)
 * [Fullscreen Galleria](https://wordpress.org/plugins/fullscreen-galleria/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/fullscreen-galleria/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/fullscreen-galleria/)
 * [Active Topics](https://wordpress.org/support/plugin/fullscreen-galleria/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/fullscreen-galleria/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/fullscreen-galleria/reviews/)

## Tags

 * [gallery](https://wordpress.org/support/topic-tag/gallery/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 2 replies
 * 2 participants
 * Last reply from: [adaldesign](https://wordpress.org/support/users/adaldesign/)
 * Last activity: [13 years, 6 months ago](https://wordpress.org/support/topic/using-shortcode-in-post-format-template/#post-3156312)
 * Status: resolved