All-in-One Video Gallery Shortcodes

Below, you’ll find a detailed guide on how to add the All-in-One Video Gallery 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 All-in-One Video Gallery Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the All-in-One Video Gallery Plugin and the shortcodes it provides:

Plugin Icon
All-in-One Video Gallery

"All-in-One Video Gallery is a powerful WordPress plugin designed to streamline and optimize your video content management. It effortlessly organizes and displays videos, enhancing user experience."

★★★★☆ (103) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 5.6.20
Included Shortcodes:
  • [aiovg_categories]
  • [aiovg_search_form]
  • [aiovg_video]
  • [aiovg_videos]
  • []
  • [aiovg_tag]
  • [aiovg_search]
  • [aiovg_user_videos]

All-in-One Video Gallery [aiovg_categories] Shortcode

The All-In-One Video Gallery shortcode is a powerful tool that allows you to display video categories in various layouts. It fetches, organizes, and presents video categories based on specific parameters. This shortcode offers flexibility in the display of categories. It supports list, dropdown, and grid layouts. It also includes options for ordering, inclusion and exclusion of categories, and pagination. The shortcode enqueues necessary style and script dependencies and sanitizes user inputs for secure operation. It also allows for customization through filters, providing developers with further control.

Shortcode: [aiovg_categories]

Parameters

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

  • ratio – Sets the aspect ratio of the video thumbnails.
  • template – Determines the layout format of the categories (list, dropdown, or grid).
  • orderby – Specifies the sorting order of the categories.
  • order – Defines the direction of the sorting order (ascending or descending).
  • hide_empty – Hides categories that do not have any videos.
  • hierarchical – Displays categories in a hierarchical structure.
  • show_count – Shows the number of videos in each category.
  • include – Includes only specific categories based on their IDs.
  • exclude – Excludes specific categories based on their IDs.
  • id – Identifies a specific category for display.
  • limit – Limits the number of categories displayed.
  • show_pagination – Enables pagination if the number of categories exceeds the limit.

Examples and Usage

Basic example – The shortcode is used to display video categories from the All-In-One Video Gallery plugin. By default, it will display all categories in a list format.

[aiovg_categories /]

Advanced examples

The shortcode can be customized with various attributes to control the output. Here are some examples:

Displaying the categories in a dropdown format:

[aiovg_categories template="dropdown" /]

Displaying the categories in a grid format:

[aiovg_categories template="grid" /]

Displaying specific categories by their IDs:

[aiovg_categories include="1,2,3" /]

Excluding specific categories by their IDs:

[aiovg_categories exclude="4,5,6" /]

Controlling the order of the categories:

[aiovg_categories orderby="name" order="ASC" /]

Displaying categories with videos only:

[aiovg_categories hide_empty="1" /]

Displaying categories hierarchically:

[aiovg_categories hierarchical="1" /]

Displaying the count of videos in each category:

[aiovg_categories show_count="1" /]

Displaying categories under a specific parent category by its ID:

[aiovg_categories id="1" /]

Limiting the number of categories to display:

[aiovg_categories limit="5" /]

Enabling pagination:

[aiovg_categories show_pagination="1" /]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_categories", array( $this, "run_shortcode_categories" ) );

Shortcode PHP function:

function run_shortcode_categories( $atts ) {	
		// Vars
		$attributes = shortcode_atts( $this->get_defaults(), $atts, 'aiovg_categories' );		
		$attributes['shortcode'] = 'aiovg_categories';	
		$attributes['ratio'] = ! empty( $attributes['ratio'] ) ? (float) $attributes['ratio'] . '%' : '56.25%';
		
		// Enqueue style dependencies
		wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-public' );
		
		// Process output
		$template = sanitize_text_field( $attributes['template'] );

		if ( 'list' == $template ) {
			$args = array(
				'taxonomy'         => 'aiovg_categories',      
				'orderby'          => sanitize_text_field( $attributes['orderby'] ),
				'order'            => sanitize_text_field( $attributes['order'] ),
				'hide_empty'       => (int) $attributes['hide_empty'], 
				'hierarchical'     => (int) $attributes['hierarchical'],                
				'show_count'       => (int) $attributes['show_count'], 
				'show_option_none' => '',   
				'title_li'         => '',
				'echo'             => 0
			);
			
			if ( ! empty( $attributes['include'] ) ) { // Include category IDs
				$args['include'] = array_map( 'intval', explode( ',', $attributes['include'] ) );
			} else {
				if ( $args['hierarchical'] ) {
					$args['child_of'] = (int) $attributes['id'];
				} else {
					$args['parent'] = (int) $attributes['id'];
				}				
			}

			if ( ! empty( $attributes['exclude'] ) ) { // Exclude category IDs
				$args['exclude'] = array_map( 'intval', explode( ',', $attributes['exclude'] ) );
			}
			
			$args = apply_filters( 'aiovg_categories_args', $args, $attributes );
			$categories_li = wp_list_categories( $args ); 

			if ( ! empty( $categories_li ) ) {
				ob_start();
				include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . "public/templates/categories-template-list.php" );
				return ob_get_clean();				
			} else {
				return aiovg_get_message( 'categories_empty' );
			}
		} elseif ( 'dropdown' == $template ) {
			wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-public' );
			
			ob_start();
			include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . "public/templates/categories-template-dropdown.php" );
			return ob_get_clean();	
		} else {
			$args = array(			
				'taxonomy'     => 'aiovg_categories',
				'orderby'      => sanitize_text_field( $attributes['orderby'] ), 
				'order'        => sanitize_text_field( $attributes['order'] ),
				'hide_empty'   => (int) $attributes['hide_empty'],
				'hierarchical' => false
			);

			if ( ! empty( $attributes['include'] ) ) { // Include category IDs
				$args['include'] = array_map( 'intval', explode( ',', $attributes['include'] ) );
			} else {
				$args['child_of'] = (int) $attributes['id'];
				$args['pad_counts'] = true;
			}

			if ( ! empty( $attributes['exclude'] ) ) { // Exclude category IDs
				$args['exclude'] = array_map( 'intval', explode( ',', $attributes['exclude'] ) );
			}

			$args = apply_filters( 'aiovg_categories_args', $args, $attributes );
			$terms = get_terms( $args );			
			
			if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
				if ( isset( $args['child_of'] ) ) {
					foreach ( $terms as $key => $term ) {
						if ( $term->parent != $args['child_of'] ) {
							unset( $terms[ $key ] );
						}
					}

					$terms = array_values( $terms );
				}

				// Pagination				
				$attributes['terms_per_page'] = (int) $attributes['limit'];

				if ( $attributes['terms_per_page'] > 0 ) {
					$offset = 0;

					if ( ! empty( $attributes['show_pagination'] ) ) {
						$attributes['count'] = count( $terms );
						$attributes['max_num_pages'] = ceil( $attributes['count'] / $attributes['terms_per_page'] );	
						
						$offset = ( $attributes['paged'] - 1 ) * $attributes['terms_per_page'];
					}
					
					$terms = array_slice( $terms, $offset, $attributes['terms_per_page'] );
				} else {
					$attributes['show_pagination'] = 0;
				}

				ob_start();
				include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . "public/templates/categories-template-grid.php" );
				return ob_get_clean();		
			} else {
				return aiovg_get_message( 'categories_empty' );
			}			
		}	
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/categories.php

All-in-One Video Gallery [aiovg_search_form] Shortcode

The All-In-One Video Gallery (AIOVG) shortcode is designed to generate a custom search form for video content. It allows users to adjust the form layout, search page, and filter options. This shortcode fetches page settings from the ‘aiovg_page_settings’ option, then it merges the provided attributes with the default ones. It also checks if the category and tag filters are enabled, adjusting the template accordingly. The shortcode enqueues necessary styles and scripts, and finally, it includes the appropriate search form template based on the ‘template’ attribute, returning its output.

Shortcode: [aiovg_search_form]

Parameters

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

  • template – Determines the layout style of the search form.
  • search_page_id – Specifies the page ID where the search results are displayed.
  • has_keyword – If set to 1, includes keyword search field in the form.
  • has_category – If set to 1, includes category selection in the search form.
  • has_tag – If set to 1, includes tag selection in the search form.

Examples and Usage

Basic example – The shortcode below will display the All-in-One Video Gallery search form with default settings. The form will appear in the ‘horizontal’ layout, and will include a keyword search field.

[aiovg_search_form]

Advanced examples

Display the search form in a ‘compact’ layout without a category or tag search field:

[aiovg_search_form template="compact" has_category=0 has_tag=0]

Display the search form with a keyword and category search field, but without a tag search field:

[aiovg_search_form has_category=1 has_tag=0]

Display the search form with a keyword, category, and tag search field:

[aiovg_search_form has_category=1 has_tag=1]

Display the search form without a keyword search field, but with a category and tag search field:

[aiovg_search_form has_keyword=0 has_category=1 has_tag=1]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_search_form", array( $this, "run_shortcode_search_form" ) );

Shortcode PHP function:

function run_shortcode_search_form( $atts ) {	
		// Vars
		$page_settings = get_option( 'aiovg_page_settings' );
		
		$attributes = array(
			'template'       => isset( $atts['template'] ) ? sanitize_text_field( $atts['template'] ) : 'horizontal',
			'search_page_id' => $page_settings['search'],
			'has_keyword'    => isset( $atts['keyword'] ) ? (int) $atts['keyword'] : 1,
			'has_category'   => isset( $atts['category'] ) ? (int) $atts['category'] : 0,
			'has_tag'        => isset( $atts['tag'] ) ? (int) $atts['tag'] : 0
		);

		if ( ! empty( $atts ) ) {
			$attributes = array_merge( $atts, $attributes );
		}

		if ( ! $attributes['has_category'] && ! $attributes['has_tag'] ) {
			$attributes['template'] = 'compact';
		}
		
		// Enqueue style dependencies
		wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-public' );

		if ( $attributes['has_tag'] ) {
			wp_enqueue_script( AIOVG_PLUGIN_SLUG . '-public' );
		}		
		
		// Process output
		ob_start();
		include apply_filters( 'aiovg_load_template', AIOVG_PLUGIN_DIR . 'public/templates/search-form-template-' . $attributes['template'] . '.php' );
		return ob_get_clean();
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/search.php

All-in-One Video Gallery [aiovg_video] Shortcode

The all-in-one-video-gallery plugin shortcode, “aiovg_video”, is designed to embed videos from various sources into a WordPress page. The shortcode accepts either an ‘id’ or ‘src’ attribute. If ‘id’ is provided, it fetches the corresponding video post. If ‘src’ is given, it identifies the video source (YouTube, Vimeo, DailyMotion, Rumble, Facebook, or direct video files) and prepares it for display. If no valid video source is found, it fetches the most recent published video post. It also enqueues necessary styles and applies filters to the attributes before generating the video player HTML.

Shortcode: [aiovg_video]

Parameters

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

  • id – Identifies the specific video to display.
  • src – Specifies the source URL of the video.
  • youtube – For YouTube video URLs.
  • vimeo – For Vimeo video URLs.
  • dailymotion – For Dailymotion video URLs.
  • rumble – For Rumble video URLs.
  • facebook – For Facebook video URLs.
  • webm – For WebM video file sources.
  • ogv – For OGV video file sources.
  • hls – For HLS video file sources.
  • dash – For DASH video file sources.
  • mp4 – For MP4 video file sources.

Examples and Usage

Basic example – Display a video by referencing its ID

[aiovg_video id=1 /]

Advanced examples

Display a video from YouTube by pasting the URL of the video in the ‘src’ attribute. The function will automatically resolve the YouTube URL and display the video.

[aiovg_video src="https://www.youtube.com/watch?v=dQw4w9WgXcQ" /]

Display a video from Vimeo by pasting the URL of the video in the ‘src’ attribute. The function will automatically resolve the Vimeo URL and display the video.

[aiovg_video src="https://vimeo.com/123456789" /]

Display a video from your local server or a CDN by providing the direct URL to the video file in the ‘src’ attribute. The function will automatically check the filetype and display the video. This example shows how to display a .mp4 video.

[aiovg_video src="https://yourwebsite.com/path/to/video.mp4" /]

Display a video from Facebook by pasting the URL of the video in the ‘src’ attribute. The function will automatically resolve the Facebook URL and display the video.

[aiovg_video src="https://www.facebook.com/yourpage/videos/123456789/" /]

Display a video from Dailymotion by pasting the URL of the video in the ‘src’ attribute. The function will automatically resolve the Dailymotion URL and display the video.

[aiovg_video src="https://www.dailymotion.com/video/x7x5ghj" /]

Display a video from Rumble by pasting the URL of the video in the ‘src’ attribute. The function will automatically resolve the Rumble URL and display the video.

[aiovg_video src="https://rumble.com/v7pn0r-spectacular-footage-of-erupting-volcano.html" /]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_video", array( $this, "run_shortcode_video" ) );

Shortcode PHP function:

function run_shortcode_video( $attributes, $content = null ) {
		if ( ! is_array( $attributes ) ) {
			$attributes = array();
		}

		$post_id = 0;
		
		if ( isset( $attributes['id'] ) && ! empty( $attributes['id'] ) ) {
			$post_id = (int) $attributes['id'];
		} else {			
			if ( isset( $attributes['src'] ) && ! empty( $attributes['src'] ) ) {
				if ( false !== strpos( $attributes['src'], 'youtube.com' ) || false !== strpos( $attributes['src'], 'youtu.be' ) ) {
					$attributes['youtube'] = aiovg_resolve_youtube_url( $attributes['src'] );
				} elseif ( false !== strpos( $attributes['src'], 'vimeo.com' ) ) {
					$attributes['vimeo'] = $attributes['src'];
				} elseif ( false !== strpos( $attributes['src'], 'dailymotion.com' ) ) {
					$attributes['dailymotion'] = $attributes['src'];
				} elseif ( false !== strpos( $attributes['src'], 'rumble.com' ) ) {
					$attributes['rumble'] = $attributes['src'];
				} elseif ( false !== strpos( $attributes['src'], 'facebook.com' ) ) {
					$attributes['facebook'] = $attributes['src'];
				} else {
					$filetype = wp_check_filetype( $attributes['src'] );
		
					if ( 'webm' == $filetype['ext'] ) {
						$attributes['webm'] = $attributes['src'];
					} elseif ( 'ogv' == $filetype['ext'] ) {
						$attributes['ogv'] = $attributes['src'];
					} elseif ( 'm3u8' == $filetype['ext'] ) {
						$attributes['hls'] = $attributes['src'];
					} elseif ( 'mpd' == $filetype['ext'] ) {
						$attributes['dash'] = $attributes['src'];
					} else {
						$attributes['mp4'] = $attributes['src'];
					}
				}

				unset( $attributes['src'] );
			} 
			
			$supported_formats = array( 'mp4', 'webm', 'ogv', 'hls', 'dash', 'youtube', 'vimeo', 'dailymotion', 'rumble', 'facebook' );
			$is_video_available = 0;

			foreach ( $supported_formats as $format ) {			
				if ( isset( $attributes[ $format ] ) ) {
					$is_video_available = 1;
					break;
				}
			}
			
			if ( 0 == $is_video_available ) {
				$args = array(				
					'post_type' => 'aiovg_videos',			
					'post_status' => 'publish',
					'posts_per_page' => 1,
					'fields' => 'ids',
					'no_found_rows' => true,
					'update_post_term_cache' => false,
					'update_post_meta_cache' => false
				);
		
				$aiovg_query = new WP_Query( $args );
				
				if ( $aiovg_query->have_posts() ) {
					$posts = $aiovg_query->posts;
					$post_id = (int) $posts[0];

					$attributes['id'] = $post_id;
				}			
			}			
		}

		// Enqueue dependencies
		wp_enqueue_style( AIOVG_PLUGIN_SLUG . '-public' );		
			
		// Output
		$attributes = apply_filters( 'shortcode_atts_aiovg_video', $attributes, $content );
		return aiovg_get_player_html( $post_id, $attributes );		
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/video.php

All-in-One Video Gallery [aiovg_videos] Shortcode

The all-in-one-video-gallery shortcode is utilized to display videos on the webpage. It fetches video content based on the attributes defined. The shortcode first checks for related attributes. If found, it identifies the category or tag page and retrieves the corresponding videos. If no videos are found, it displays a ‘videos_empty’ message.

Shortcode: [aiovg_videos]

Parameters

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

  • related – Determines if related videos are displayed
  • aiovg_category – Filters videos by specific category
  • aiovg_tag – Filters videos by specific tag
  • videos_empty – Message displayed when no videos are found

Examples and Usage

Basic example – Displaying videos using the ‘aiovg_videos’ shortcode without any parameters. This will display all videos as the shortcode uses the default attributes.

[aiovg_videos /]

Advanced examples

Displaying videos from a specific category. The ‘category’ attribute is used to filter videos based on their assigned category. Replace ‘category_id’ with the actual ID of the category.

[aiovg_videos category="category_id" /]

Displaying videos tagged with a specific tag. The ‘tag’ attribute is used to filter videos based on their assigned tags. Replace ‘tag_id’ with the actual ID of the tag.

[aiovg_videos tag="tag_id" /]

Displaying related videos. The ‘related’ attribute is used to display videos that are related to the current video being viewed. Set the ‘related’ attribute to ‘true’ to enable this feature.

[aiovg_videos related="true" /]

Combining multiple attributes. You can combine multiple attributes to further customize the output of the shortcode. In this example, we are displaying related videos from a specific category.

[aiovg_videos category="category_id" related="true" /]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_videos", array( $this, "run_shortcode_videos" ) );

Shortcode PHP function:

function run_shortcode_videos( $atts ) {		
		$attributes = shortcode_atts( $this->get_defaults(), $atts, 'aiovg_videos' );
		$attributes['shortcode'] = 'aiovg_videos';
				
		if ( ! empty( $attributes['related'] ) ) {
			// Category page
			if ( $term_slug = get_query_var( 'aiovg_category' ) ) {         
				$term = get_term_by( 'slug', sanitize_text_field( $term_slug ), 'aiovg_categories' );
				$attributes['category'] = $term->term_id;
			}

			// Tag page
			if ( $term_slug = get_query_var( 'aiovg_tag' ) ) {         
				$term = get_term_by( 'slug', sanitize_text_field( $term_slug ), 'aiovg_tags' );
				$attributes['tag'] = $term->term_id;
			}
		}
		
		$content = $this->get_content( $attributes );
		
		if ( empty( $content ) ) {
			$content = aiovg_get_message( 'videos_empty' );
		}
		
		return $content;		
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/videos.php

All-in-One Video Gallery [null] Shortcode

The All-In-One-Video-Gallery shortcode, [aiovg_category], is used to display a specific video category. It fetches the category either by slug or ID, and if found, it generates the category content. The content includes a back button, category description, videos within the category, and any sub-categories. If no videos or sub-categories are found, it displays a ‘videos empty’ message. If the category is not found, it defaults to displaying all categories.

Shortcode: [null]

Parameters

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

  • id – unique identifier of the video category

Examples and Usage

Basic example – Display a specific category by its ID.

[aiovg_category id=1 /]

Advanced examples

Display a specific category by its slug. This can be useful if you want to avoid using IDs and prefer to use more human-readable identifiers.

[aiovg_category slug="my-category-slug" /]

Combining multiple attributes. In this example, we are displaying a category by its ID and also specifying a limit to the number of sub-categories that are displayed.

[aiovg_category id=1 limit=3 /]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_category", array( $this, "run_shortcode_category" ) );

Shortcode PHP function:

function run_shortcode_category( $atts ) {	
		$term_slug = get_query_var( 'aiovg_category' );
		
		if ( ! empty( $term_slug ) ) {
			$term = get_term_by( 'slug', sanitize_title( $term_slug ), 'aiovg_categories' );
		} elseif ( ! empty( $atts['id'] ) ) {			
			$term = get_term_by( 'id', (int) $atts['id'], 'aiovg_categories' );
		}
		
		if ( isset( $term ) && ! empty( $term ) ) {
			$categories_settings = get_option( 'aiovg_categories_settings' );

			$content = '';
			
			if ( ! empty( $categories_settings['back_button'] ) ) {
				$page_settings = get_option( 'aiovg_page_settings' );

				$back_button_url  = get_permalink( $page_settings['category'] );
				$back_button_text = __( 'All Categories', 'all-in-one-video-gallery' );

				if ( $term->parent > 0 ) {
					$parent_term = get_term_by( 'id', $term->parent, 'aiovg_categories' );

					$back_button_url  = aiovg_get_category_page_url( $parent_term );
					$back_button_text = $parent_term->name;
				}

				$back_button_url = apply_filters( 'aiovg_back_to_categories_link', $back_button_url );

				if ( ! empty( $back_button_url ) ) {
					$content .= sprintf( 
						'<p class="aiovg aiovg-categories-nav"><a href="%s">&larr; %s</a></p>',
						esc_url( $back_button_url ),
						$back_button_text
					);						
				}
			}

			if ( ! empty( $term->description ) ) {
				$content .= sprintf( '<div class="aiovg-category-description">%s</div>', wp_kses_post( nl2br( $term->description ) ) );
			}

			// Videos
			$attributes = shortcode_atts( $this->get_defaults(), $atts, 'aiovg_category' );
			$attributes['shortcode'] = 'aiovg_category';
			$attributes['category'] = $term->term_id;

			$videos = $this->get_content( $attributes );
			
			// Sub Categories
			$_attributes = array();
			$_attributes[] = 'id="' . $term->term_id . '"';
			$_attributes[] = 'limit="0"';

			if ( ! empty( $content ) ) {
				$_attributes[] = 'title="' . __( 'Sub Categories', 'all-in-one-video-gallery' ) . '"';
			}
			
			$sub_categories = do_shortcode( '[aiovg_categories ' . implode( ' ', $_attributes ) . ']' );				
			if ( $sub_categories == aiovg_get_message( 'categories_empty' ) ) {
				$sub_categories = '';
			}
			
			// ...
			if ( empty( $videos ) && empty( $sub_categories ) ) {
				$content .= aiovg_get_message( 'videos_empty' );
			} else {
				$content .= $videos;
				$content .= $sub_categories;
			}

			return $content;
		}
		
		return do_shortcode( '[aiovg_categories]' );	
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/videos.php

All-in-One Video Gallery [aiovg_tag] Shortcode

The All-In-One-Video-Gallery plugin shortcode “aiovg_tag” is designed to display videos tagged with a specific term. It fetches the term either from the URL or the ‘id’ attribute. If a term is found, it retrieves the page settings and constructs the content to be displayed, starting with the term’s description. It then fetches the videos associated with the term. If no videos are found, it displays a ‘videos_empty’ message. In case no term is found, it tries to display a list of all tags. If still no tags are found, it displays a ‘tags_empty’ message.

Shortcode: [aiovg_tag]

Parameters

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

  • id – Identifier for the specific video tag to display

Examples and Usage

Basic example – A simple usage of the aiovg_tag shortcode to display videos associated with a specific tag by its ID.

[aiovg_tag id=1 /]

Advanced examples

Using the aiovg_tag shortcode to display videos associated with a specific tag by its slug. The videos will be displayed only if the slug exists.

[aiovg_tag slug="my-video-tag" /]

Using the aiovg_tag shortcode to display videos associated with a specific tag by its ID. If the tag ID does not exist, it will display a message indicating that there are no videos for this tag.

[aiovg_tag id=100 /]

Using the aiovg_tag shortcode without any attributes. This will display a list of all tags in your video gallery.

[aiovg_tag /]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_tag", array( $this, "run_shortcode_tag" ) );

Shortcode PHP function:

function run_shortcode_tag( $atts ) {	
		$term_slug = get_query_var( 'aiovg_tag' );
		
		if ( ! empty( $term_slug ) ) {
			$term = get_term_by( 'slug', sanitize_title( $term_slug ), 'aiovg_tags' );
		} elseif ( ! empty( $atts['id'] ) ) {			
			$term = get_term_by( 'id', (int) $atts['id'], 'aiovg_tags' );
		}
		
		if ( isset( $term ) && ! empty( $term ) ) {
			$page_settings = get_option( 'aiovg_page_settings' );
			$content = '';
	
			if ( ! empty( $term->description ) ) {
				$content .= sprintf( '<p class="aiovg-tag-description">%s</p>', wp_kses_post( nl2br( $term->description ) ) );
			}

			// Videos
			$attributes = shortcode_atts( $this->get_defaults(), $atts, 'aiovg_tag' );
			$attributes['shortcode'] = 'aiovg_tag';
			$attributes['tag'] = $term->term_id;

			$content .= $this->get_content( $attributes );

			if ( empty( $content ) ) {
				$content .= aiovg_get_message( 'videos_empty' );
			}
	
			return $content;
		} else {
			$args = array( 
				'taxonomy' => 'aiovg_tags', 
				'format'   => 'array',
				'echo'     => false 
			);

			$args = apply_filters( 'aiovg_tags_args', $args, $atts );
			$tags = wp_tag_cloud( $args );

			if ( ! empty( $tags ) ) {
				return '<div class="aiovg aiovg-tags-list">' . implode( "\n", $tags ) . '</div>';
			}
		}
		
		return aiovg_get_message( 'tags_empty' );
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/videos.php

All-in-One Video Gallery [aiovg_search] Shortcode

The All-In-One Video Gallery shortcode is a powerful tool that enables searching within video content. It accepts ‘vi’ for search query and ‘ca’ for category from the URL parameters. If no category is provided or it’s empty, it excludes certain categories based on the ‘exclude_search_form’ meta key. It also accepts ‘ta’ for tags. The shortcode then retrieves the content based on these attributes. If no content is found, it displays a ‘videos_empty’ message.

Shortcode: [aiovg_search]

Parameters

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

  • vi – The search query for the video
  • ca – Category ID to filter videos
  • ta – Tag ID to filter videos

Examples and Usage

Basic example – Utilizes the “aiovg_search” shortcode to display a search form for the All-In-One Video Gallery.

[aiovg_search /]

Advanced examples

Implementing the shortcode to display a search form and automatically populate it with a specific search query. This can be useful for directing users towards a specific set of videos.

[aiovg_search vi="tutorial" /]

Applying the shortcode to display a search form and pre-select a specific category. This is useful for guiding users towards a specific category of videos.

[aiovg_search ca="action" /]

Using the shortcode to display a search form and pre-select a specific tag. This can be useful for guiding users towards a specific tag of videos.

[aiovg_search ta="adventure" /]

Combining the shortcode to display a search form, pre-populate it with a specific search query, and pre-select a specific category and tag. This is the most advanced use-case, allowing you to guide users towards a very specific set of videos.

[aiovg_search vi="tutorial" ca="action" ta="adventure" /]

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_search", array( $this, "run_shortcode_search" ) );

Shortcode PHP function:

function run_shortcode_search( $atts ) {	
		$attributes = shortcode_atts( $this->get_defaults(), $atts, 'aiovg_search' );
		$attributes['shortcode'] = 'aiovg_search';
		
		if ( isset( $_GET['vi'] ) ) {
			$attributes['search_query'] = $_GET['vi'];
		}
		
		if ( isset( $_GET['ca'] ) ) {
			$attributes['category'] = $_GET['ca'];
		}

		if ( ! isset( $_GET['ca'] ) || ( isset( $_GET['ca'] ) && empty( $_GET['ca'] ) ) ) {
			$categories_excluded = get_terms( array(
				'taxonomy'   => 'aiovg_categories',
				'hide_empty' => false,
				'fields'     => 'ids',
				'meta_key'   => 'exclude_search_form',
				'meta_value' => 1
			) );

			if ( ! empty( $categories_excluded ) && ! is_wp_error( $categories_excluded ) ) {
				$attributes['category_exclude'] = $categories_excluded;
			}
		}

		if ( isset( $_GET['ta'] ) ) {
			$attributes['tag'] = $_GET['ta'];
		}
		
		$content = $this->get_content( $attributes );
		
		if ( empty( $content ) ) {
			$content = aiovg_get_message( 'videos_empty' );
		}
		
		return $content;		
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/videos.php

All-in-One Video Gallery [aiovg_user_videos] Shortcode

The All-In-One-Video-Gallery plugin shortcode “aiovg_user_videos” fetches and displays videos uploaded by a specific user. It checks for a user slug. If not found, it retrieves the slug from the author meta using the ID provided in the shortcode attributes. If no ID is provided, it uses the current logged-in user’s ID. If a user slug is found, it fetches the videos associated with that user. If no videos are found, it returns a ‘videos_empty’ message.

Shortcode: [aiovg_user_videos]

Parameters

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

  • id – The unique identifier for a specific user

Examples and Usage

Basic example – Show videos of the currently logged-in user

[aiovg_user_videos]

Advanced examples

Display videos of a specific user by using their user ID. In this case, user ID is 5.

[aiovg_user_videos id=5]

Display videos of a specific user by using their user slug. In this case, user slug is ‘john-doe’.

[aiovg_user_videos user_slug='john-doe']

Combine multiple parameters to create more specific shortcodes. This example shows videos of a specific user (user ID is 5) and overrides some default settings for the video gallery.

[aiovg_user_videos id=5 columns=3 limit=10]

Note: In the advanced examples, ‘columns’ refers to the number of video columns in the gallery, and ‘limit’ refers to the maximum number of videos to show.

PHP Function Code

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

Shortcode line:

add_shortcode( "aiovg_user_videos", array( $this, "run_shortcode_user_videos" ) );

Shortcode PHP function:

function run_shortcode_user_videos( $atts ) {	
		$user_slug = get_query_var( 'aiovg_user' );
		$content   = '';		
		
		if ( empty( $user_slug ) ) {
			if ( ! empty( $atts['id'] ) ) {
				$user_slug = get_the_author_meta( 'user_nicename', (int) $atts['id'] );	
			} elseif ( is_user_logged_in() ) {
				$user_slug = get_the_author_meta( 'user_nicename', get_current_user_id() );				
			}
		}
		
		if ( ! empty( $user_slug ) ) {		
			$attributes = shortcode_atts( $this->get_defaults(), $atts, 'aiovg_user_videos' );
			$attributes['shortcode'] = 'aiovg_user_videos';
			$attributes['user_slug'] = $user_slug;

			$content = $this->get_content( $attributes );		
		} else {
			$content = do_shortcode( '[aiovg_videos]' );	
		}
		
		if ( empty( $content ) ) {
			$content = aiovg_get_message( 'videos_empty' );
		}
		
		return $content;	
	}

Code file location:

all-in-one-video-gallery/all-in-one-video-gallery/public/videos.php

Conclusion

Now that you’ve learned how to embed the All-in-One Video Gallery 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 *