Accordion Slider Gallery Shortcode

Below, you’ll find a detailed guide on how to add the Accordion Slider Gallery Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Accordion Slider Gallery Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Accordion Slider Gallery Plugin and the shortcodes it provides:

Plugin Icon
Accordion Slider Gallery

"Accordion Slider Gallery is a dynamic WordPress plugin that allows you to create responsive, touch-friendly slide galleries. It beautifully organizes your images for streamlined browsing."

★★★★✩ (3) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [accordion-slider]

Accordion Slider Gallery [accordion-slider] Shortcode

The Accordion Slider shortcode is a powerful tool that displays a dynamic image gallery. It retrieves images from a specific post, then organizes them into an attractive accordion slider.

Shortcode: [accordion-slider]


Here is a list of all possible accordion-slider shortcode parameters and attributes:

  • id – The unique identifier of the accordion slider gallery

Examples and Usage

Basic example – Display an accordion slider by referencing its ID

[accordion-slider id=1 /]

Advanced examples

Display multiple accordion sliders by referencing their IDs. It’s important to note that you need to separate each ID with a comma.

[accordion-slider id=1,2,3 /]

Display an accordion slider by referencing its ID and specifying a custom post type. This example assumes that you have a custom post type named ‘custom_accordion_slider’.

[accordion-slider id=1 post_type='custom_accordion_slider' /]

Display an accordion slider by referencing its ID and ordering the slides in descending order.

[accordion-slider id=1 orderby='DESC' /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'accordion-slider', array( $this, 'accordion_slider_shortcode_handler' ) );

Shortcode PHP function:

function accordion_slider_shortcode_handler( $Id ) {
		// Id return id

			$WPSM_Gallery_ID = "";
			$WPSM_Gallery_ID = $Id['id'];

		$post_type = "accordion_slider";
		$AllTeams = array(  'p' => $WPSM_Gallery_ID, 'post_type' => $post_type, 'orderby' => 'ASC');
	    $loop = new WP_Query( $AllTeams );
		while ( $loop->have_posts() ) : $loop->the_post();
			$PostId = get_the_ID();
			$settings = get_post_meta( $PostId, 'accordion-slider-settings', true );
			$default  = Accordion_Slider_WP_CPT_Fields_Helper::get_defaults();
			$settings = wp_parse_args( $settings, $default );

			/*$All_data = get_post_meta( $PostId, 'slider-images', true); //image data
			$TotalCount = sizeof($All_data);*/

			$images = apply_filters( 'accordion_slider_before_shuffle_images', get_post_meta( $PostId, 'slider-images', true ), $settings );
			//$url = wp_get_attachment_image_src($id, 'as_accordion_slider', true);

			require "templates/design/accordion-slider/accordion-slider.php";


    return ob_get_clean();

Code file location:



Now that you’ve learned how to embed the Accordion Slider Gallery Plugin shortcode, 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.


Leave a Reply

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