YouTube Video Gallery Shortcodes

Below, you’ll find a detailed guide on how to add the YouTube Video Gallery by YouTube Showcase Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the YouTube Video Gallery by YouTube Showcase Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the YouTube Video Gallery by YouTube Showcase Plugin and the shortcodes it provides:

Plugin Icon
YouTube Video Gallery by YouTube Showcase – Video Gallery Plugin for WordPress

"YouTube Video Gallery by YouTube Showcase is a handy WordPress plugin. It simplifies the process of creating and customizing a dynamic video gallery from your YouTube content."

★★★★☆ (119) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [emd_mb_meta]
  • [emd_old_forms_lite_shc]
  • [emd_form]
  • [video_grid]
  • [video_indicators]
  • [video_items]
  • [video_gallery]

YouTube Video Gallery [emd_mb_meta] Shortcode

The YouTube Showcase shortcode is a versatile tool that fetches and displays different types of content. It retrieves text, files, images, and taxonomy terms based on specified attributes. It uses the ‘post_id’ to gather the relevant data. For files and images, it creates a list with links or thumbnails. For taxonomy terms, it generates a list with links to each term. Other multiple fields are displayed in a simple list format.

Shortcode: [emd_mb_meta]

Parameters

Here is a list of all possible emd_mb_meta shortcode parameters and attributes:

  • type – Defines the type of the meta, such as ‘text’, ‘file’, ‘image’, ‘taxonomy’.
  • post_id – Specifies the ID of the post to fetch metadata from.
  • meta_key – Specifies the key of the metadata to be fetched.
  • link – Determines if the image should be linked to the full-size image.
  • taxonomy – Specifies the taxonomy for which terms should be fetched.

Examples and Usage

Basic example – A simple usage of the shortcode to retrieve post metadata using the meta key.

[emd_mb_meta meta_key="your_meta_key" /]

Advanced examples

Using the shortcode to display a list of uploaded files related to a specific post. The shortcode is supplied with the post_id and type parameters.

[emd_mb_meta type="file" post_id="123" meta_key="your_meta_key" /]

Using the shortcode to display a list of images uploaded with the post. The shortcode is supplied with the post_id, type, and link parameters. If the link parameter is set to true, the images will be linked to their full-size versions.

[emd_mb_meta type="image" post_id="123" meta_key="your_meta_key" link="true" /]

Using the shortcode to display a list of terms from a specific taxonomy related to a post. The shortcode is supplied with the post_id, type, and taxonomy parameters.

[emd_mb_meta type="taxonomy" post_id="123" meta_key="your_meta_key" taxonomy="your_taxonomy" /]

Using the shortcode to display a list of multiple fields related to a post. The shortcode is supplied with the post_id and meta_key parameters.

[emd_mb_meta post_id="123" meta_key="your_meta_key" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [emd_mb_meta] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'emd_mb_meta', array( __CLASS__, 'shortcode' ) );

Shortcode PHP function:

function shortcode( $atts )
		{
			$atts = wp_parse_args( $atts, array(
				'type'    => 'text',
				'post_id' => get_the_ID(),
			) );
			if ( empty( $atts['meta_key'] ) )
				return '';

			$meta = self::meta( $atts['meta_key'], $atts, $atts['post_id'] );

			// Get uploaded files info
			if ( in_array( $atts['type'], array( 'file', 'file_advanced' ) ) )
			{
				$content = '<ul>';
				foreach ( $meta as $file )
				{
					$content .= sprintf(
						'<li><a href="%s" title="%s">%s</a></li>',
						$file['url'],
						$file['title'],
						$file['name']
					);
				}
				$content .= '</ul>';
			}

			// Get uploaded images info
			elseif ( in_array( $atts['type'], array( 'image', 'plupload_image', 'thickbox_image', 'image_advanced' ) ) )
			{
				$content = '<ul>';
				foreach ( $meta as $image )
				{
					// Link thumbnail to full size image?
					if ( isset( $atts['link'] ) && $atts['link'] )
					{
						$content .= sprintf(
							'<li><a href="%s" title="%s"><img src="%s" alt="%s" title="%s" /></a></li>',
							$image['full_url'],
							$image['title'],
							$image['url'],
							$image['alt'],
							$image['title']
						);
					}
					else
					{
						$content .= sprintf(
							'<li><img src="%s" alt="%s" title="%s" /></li>',
							$image['url'],
							$image['alt'],
							$image['title']
						);
					}
				}
				$content .= '</ul>';
			}

			// Get post terms
			elseif ( 'taxonomy' == $atts['type'] )
			{
				$content = '<ul>';
				foreach ( $meta as $term )
				{
					$content .= sprintf(
						'<li><a href="%s" title="%s">%s</a></li>',
						get_term_link( $term, $atts['taxonomy'] ),
						$term->name,
						$term->name
					);
				}
				$content .= '</ul>';
			}

			// Normal multiple fields: checkbox_list, select with multiple values
			elseif ( is_array( $meta ) )
			{
				$content = '<ul><li>' . implode( '</li><li>', $meta ) . '</li></ul>';
			}

			else
			{
				$content = $meta;
			}

			return apply_filters( __FUNCTION__, $content );
		}

Code file location:

youtube-showcase/youtube-showcase/assets/ext/emd-meta-box/inc/helpers.php

YouTube Video Gallery [emd_old_forms_lite_shc] Shortcode

The ’emd_old_forms_lite_shc’ shortcode is a function in the Youtube-Showcase plugin that retrieves and displays old forms. It checks if a tag is present, obtains the form ID, and returns the shortcode of the corresponding form. If a ‘set’ attribute is provided, it includes it in the returned shortcode.

Shortcode: [emd_old_forms_lite_shc]

Parameters

Here is a list of all possible emd_old_forms_lite_shc shortcode parameters and attributes:

  • $atts – array holding shortcode attributes, for example, ‘set’
  • $content – enclosed content within the shortcode, if any
  • $tag – shortcode tag, used to identify the form
  • set – attribute in $atts array, used to specify additional form settings

Examples and Usage

Basic example – The basic usage of the shortcode will display a form by using its ID. This ID is stored in the ’emd_form_id_’ option in the database. The shortcode will look for the form with that ID and display it on the page.

[emd_old_forms_lite_shc tag="your_form_tag" /]

Advanced examples

Display a form by using its ID and a set of parameters. The shortcode will look for the form with that ID and display it on the page. The ‘set’ parameter allows you to specify a set of options for the form.

[emd_old_forms_lite_shc tag="your_form_tag" set="your_set_options" /]

Display a form by using its ID and a set of parameters. If the form with that ID is not found, the shortcode will return an empty string. The ‘set’ parameter allows you to specify a set of options for the form. In this example, we are using two sets of options ‘option1’ and ‘option2’.

[emd_old_forms_lite_shc tag="your_form_tag" set="option1, option2" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [emd_old_forms_lite_shc] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode($fkey,'emd_old_forms_lite_shc');

Shortcode PHP function:

function emd_old_forms_lite_shc($atts,$content,$tag){
	if(!empty($tag)){
		$fid = get_option('emd_form_id_' . $tag,0);
		if(!empty($fid)){
			if(!empty($atts['set'])){
				return do_shortcode("[emd_form id='" . $fid . "' set=\"" . $atts['set'] . "\"]");
			}
			else {
				return do_shortcode("[emd_form id='" . $fid . "']");
			}
		}
	}
}

Code file location:

youtube-showcase/youtube-showcase/includes/emd-form-builder-lite/emd-form-builder.php

YouTube Video Gallery [emd_form] Shortcode

The YouTube Showcase shortcode, ’emd_form’, dynamically displays a form based on the form ID passed in its attributes. It validates user access, form schedule, and submit count before rendering the form.

Shortcode: [emd_form]

Parameters

Here is a list of all possible emd_form shortcode parameters and attributes:

  • id – Unique identifier of the form to be displayed.
  • set – Allows to set additional attributes for the form.
  • status – Shows the status of the form, such as errors.
  • resp – Shows the response message if there is an error.

Examples and Usage

Basic example – Display a form using its post ID

[emd_form id=123 /]

Advanced examples

Display a form using its post ID and set additional parameters

[emd_form id=123 set="parameter_value" /]

Display a form by referencing both ID and set. The form will first try to load by ID, but if not found, it will try to load by set.

[emd_form id=123 set="parameter_value" /]

Display a form by ID and set multiple parameters. This example sets two parameters, “parameter1” and “parameter2”.

[emd_form id=123 set="parameter1_value" set="parameter2_value" /]

Please replace “123” with your actual form ID and “parameter_value”, “parameter1_value”, “parameter2_value” with your actual parameters.

PHP Function Code

In case you have difficulties debugging what causing issues with [emd_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('emd_form','emd_form_builder_lite_show_form');

Shortcode PHP function:

function emd_form_builder_lite_show_form($atts){
	if(!empty($atts['id'])){
		$myform = get_post($atts['id']);
		if(empty($myform)){
			return;
		}
		$fcontent = json_decode($myform->post_content,true);
		$app = $fcontent['app'];
		$shc_list = get_option($app . '_shc_list',Array());
		if(empty($shc_list['has_form_lite']) && function_exists('emd_form_builder_show_form')){
			return emd_form_builder_show_form($atts);
		}
		$fentity = $fcontent['entity'];
		$atts_set = '';
		if (!empty($atts['set'])) {
			$atts_set = $atts['set'];
		}
		$show_form = 1;
		$caps = get_option($app . '_add_caps',Array());
		if(!empty($caps['view_' . $fcontent['name']])){
			$show_form = 0;
			if(current_user_can('view_' . $fcontent['name'])){
				$show_form = 1;
			}
		}
		else {
			$show_form = 1;
		}
		//check submit count
		if(!empty($fcontent['settings']['disable_after'])){
			$submits = get_posts(array('post_type' => $fcontent['entity'],'meta_key'=>'wpas_form_name','meta_value'=>$fcontent['name'],'posts_per_page'=>-1, 'fields' => 'ids'));
			$count_submits = count($submits);
			if($count_submits > $fcontent['settings']['disable_after']){
				$show_form = 0;
			}
		}
		//form schedule
		if($show_form == 1 && !empty($fcontent['settings']['schedule_start'])){
			$now = date("Y-m-d H:i:s");
			if($now < $fcontent['settings']['schedule_start']){
				$show_form = 0;
			}
		}
		if($show_form == 1 && !empty($fcontent['settings']['schedule_end'])){
			$now = date("Y-m-d H:i:s");
			if($now > $fcontent['settings']['schedule_end']){
				$show_form = 0;
			}
		}
		$access_views = get_option($app . '_access_views', Array());
		if (!current_user_can('view_' . $fcontent['name']) && !empty($access_views['forms']) && in_array($fcontent['name'], $access_views['forms'])) {
			$show_form = 0;
		}
		$show_form = apply_filters('emd_check_show_form',$show_form,$app,$fcontent['name']);
		if ($show_form == 1) {
			if (!empty($fcontent['settings']['login_reg'])) {
				$show_login_register = $fcontent['settings']['login_reg'];
				if (!is_user_logged_in() && $show_login_register != 'none') {
					do_action('emd_show_login_register_forms', $app, $fcontent, $show_login_register);
					return;
				}
			}
			$status = '';
			$error = '';
			if(!empty($_GET['status'])){
				$status = sanitize_text_field($_GET['status']);
			}	
			if($status == 'error' && !empty($_GET['resp'])){
				$error = array_map('sanitize_text_field',json_decode($_GET['resp']));
			}
			return emd_form_builder_lite_render_form($myform->ID,$app,$fcontent,$error,$status,$atts_set);	
		} else {
			$noaccess_msg = $fcontent['settings']['noaccess_msg'];
			return "<div class='alert alert-info not-authorized'>" . $noaccess_msg . "</div>";
		}
	}
}

Code file location:

youtube-showcase/youtube-showcase/includes/emd-form-builder-lite/emd-form-frontend.php

YouTube Video Gallery [video_grid] Shortcode

The ‘video_grid’ shortcode from the YouTube Showcase plugin displays a grid of videos on your WordPress page. It first checks user authorization, enqueues necessary scripts and styles, and applies custom CSS and JS. If access is denied, an alert message is shown.

Shortcode: [video_grid]

Examples and Usage

Basic example – Showcases a video grid by referencing the shortcode ‘video_grid’ without any additional parameters.

[video_grid /]

Advanced examples

Display a video grid with specific attributes. In this case, the shortcode ‘video_grid’ is used with two additional parameters: ‘category’ and ‘count’. The ‘category’ parameter filters the videos by category, and the ‘count’ parameter limits the number of videos displayed in the grid.

[video_grid category="music" count=5 /]

Another advanced usage could involve using the ‘video_grid’ shortcode with a ‘sort_by’ parameter. This parameter allows you to arrange the videos in the grid according to a specific order. For instance, you could sort the videos by ‘date’ to display the most recent videos first.

[video_grid sort_by="date" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [video_grid] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('video_grid', 'video_grid_list');

Shortcode PHP function:

function video_grid_list($atts) {
	$show_shc = 1;
	$show_shc = apply_filters('emd_show_shc', $show_shc, 'video_grid');
	if ($show_shc == 1) {
		youtube_showcase_enq_bootstrap();
		wp_enqueue_script('ytscjs');
		wp_enqueue_script('ytsc-js');
		wp_enqueue_style('emd-pagination');
		add_action('wp_footer', 'youtube_showcase_enq_allview');
		youtube_showcase_enq_custom_css_js();
		$list = youtube_showcase_video_grid_set_shc($atts);
	} else {
		$list = '<div class="alert alert-info not-authorized">You are not authorized to access this content.</div>';
		$list = apply_filters('emd_no_access_msg_shc', $list, 'video_grid');
	}
	return $list;
}

Code file location:

youtube-showcase/youtube-showcase/includes/entities/emd-video-shortcodes.php

YouTube Video Gallery [video_indicators] Shortcode

The YouTube Showcase shortcode ‘video_indicators’ is designed to display a list of video indicators. It enqueues necessary scripts, styles, and applies filters for customization. If the shortcode is allowed, it enqueues Bootstrap, JavaScript, and CSS files, and sets the video indicators list. If not authorized, it displays an alert message.

Shortcode: [video_indicators]

Examples and Usage

Basic example – Showcases a list of video indicators without any additional parameters

[video_indicators /]

Advanced examples

Display a specific number of video indicators by using the ‘count’ parameter. Here we are displaying 5 video indicators.

[video_indicators count=5 /]

Filter the video indicators list by a specific category by using the ‘category’ parameter. Here we are displaying video indicators from the ‘Music’ category.

[video_indicators category='Music' /]

Combine multiple parameters to display a specific number of video indicators from a specific category. Here we are displaying 5 video indicators from the ‘Music’ category.

[video_indicators count=5 category='Music' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [video_indicators] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('video_indicators', 'video_indicators_list');

Shortcode PHP function:

function video_indicators_list($atts) {
	$show_shc = 1;
	$show_shc = apply_filters('emd_show_shc', $show_shc, 'video_indicators');
	if ($show_shc == 1) {
		youtube_showcase_enq_bootstrap();
		wp_enqueue_script('ytscjs');
		wp_enqueue_script('ytsc-js');
		wp_enqueue_style('emd-pagination');
		add_action('wp_footer', 'youtube_showcase_enq_allview');
		youtube_showcase_enq_custom_css_js();
		$list = youtube_showcase_video_indicators_set_shc($atts);
	} else {
		$list = '<div class="alert alert-info not-authorized">You are not authorized to access this content.</div>';
		$list = apply_filters('emd_no_access_msg_shc', $list, 'video_indicators');
	}
	return $list;
}

Code file location:

youtube-showcase/youtube-showcase/includes/entities/emd-video-shortcodes.php

YouTube Video Gallery [video_items] Shortcode

The YouTube Showcase shortcode, ‘video_items’, displays a list of video items. It first checks if the user is authorized to access the content. If authorized, it enqueues necessary styles and scripts, and generates the video list. If not, it displays an ‘unauthorized’ message.

Shortcode: [video_items]

Examples and Usage

Basic example – Showcases a list of video items on your website.

[video_items]

Advanced examples

Display a specific number of video items. For instance, if you want to display only 5 video items, you can specify the count in the shortcode like this:

[video_items count=5]

Display video items from a specific category. If you want to show video items from the category ‘Music’, you can specify the category in the shortcode like this:

[video_items category='Music']

Combine multiple parameters. If you want to display 5 video items from the category ‘Music’, you can combine the parameters like this:

[video_items count=5 category='Music']

PHP Function Code

In case you have difficulties debugging what causing issues with [video_items] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('video_items', 'video_items_list');

Shortcode PHP function:

function video_items_list($atts) {
	$show_shc = 1;
	$show_shc = apply_filters('emd_show_shc', $show_shc, 'video_items');
	if ($show_shc == 1) {
		youtube_showcase_enq_bootstrap();
		wp_enqueue_style('emd-pagination');
		add_action('wp_footer', 'youtube_showcase_enq_allview');
		youtube_showcase_enq_custom_css_js();
		$list = youtube_showcase_video_items_set_shc($atts);
	} else {
		$list = '<div class="alert alert-info not-authorized">You are not authorized to access this content.</div>';
		$list = apply_filters('emd_no_access_msg_shc', $list, 'video_items');
	}
	return $list;
}

Code file location:

youtube-showcase/youtube-showcase/includes/entities/emd-video-shortcodes.php

YouTube Video Gallery [video_gallery] Shortcode

The YouTube Showcase plugin shortcode, ‘video_gallery’, is designed to display an integrated video gallery. Upon execution, it first checks the user’s permission to view the gallery. If access is denied, an error message is displayed. If access is granted, the necessary scripts are enqueued. The shortcode also supports a filter attribute, which can be used to filter the videos displayed in the gallery. Finally, it returns the layout of the video gallery, which is defined in the ‘video-gallery’ template part.

Shortcode: [video_gallery]

Examples and Usage

Basic example – Use the shortcode to display a simple video gallery on your site.

[video_gallery]

Advanced examples

Filter the video gallery based on specific criteria. The following example will display only the videos that meet the filter conditions set in the shortcode.

[video_gallery filter="criteria"]

Use the shortcode to display a video gallery with a customized message for users who are not authorized to access the gallery. Replace the ‘custom_message’ with your own text.

[video_gallery no_access_msg="custom_message"]

Display the video gallery and load a specific script in the footer of your site. This can be useful for adding custom functionalities or features to your video gallery.

[video_gallery wp_footer="script_name"]

PHP Function Code

In case you have difficulties debugging what causing issues with [video_gallery] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('video_gallery', 'youtube_showcase_get_integ_video_gallery');

Shortcode PHP function:

function youtube_showcase_get_integ_video_gallery($atts) {
	$no_access_msg = __('You are not allowed to access to this area. Please contact the site administrator.', 'youtube-showcase');
	$access_views = get_option('youtube_showcase_access_views', Array());
	if (!current_user_can('view_video_gallery') && !empty($access_views['integration']) && in_array('video_gallery', $access_views['integration'])) {
		return $no_access_msg;
	} else {
		wp_enqueue_script('jquery');
		youtube_showcase_enq_bootstrap();
		do_action('emd_enqueue_integ_view', 'youtube-showcase', 'video_gallery');
		wp_enqueue_script('video-gallery-js');
		add_action('wp_footer', 'youtube_showcase_enq_allview');
		if (!empty($atts) && !empty($atts['filter'])) {
			$shc_filter = "video_gallery_filter";
			global $ {
				$shc_filter
			};
			$ {
				$shc_filter
			} = $atts['filter'];
		}
		ob_start();
		emd_get_template_part('youtube-showcase', 'integration', 'video-gallery');
		$layout = ob_get_clean();
		return $layout;
	}
}

Code file location:

youtube-showcase/youtube-showcase/includes/integration-shortcodes.php

Conclusion

Now that you’ve learned how to embed the YouTube Video Gallery by YouTube Showcase Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *