Below, you’ll find a detailed guide on how to add the Album Gallery – WordPress 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 Album Gallery – WordPress Gallery Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Album Gallery – WordPress Gallery Plugin and the shortcodes it provides:
"Album Gallery – WordPress Gallery is a versatile plugin that enhances your site with beautiful photo galleries. With this new-album-gallery plugin, display your images in a stunning and organized manner."
- [AGAL]
Album Gallery [AGAL] Shortcode
The New Album Gallery (NAG) shortcode adds a customizable photo gallery to a WordPress post. It enqueues necessary JavaScript and CSS files for the gallery’s functionality and appearance. This shortcode activates the nag_album_gallery_shortcode function, which generates the gallery’s HTML output. It uses jQuery and other scripts for smooth navigation. Additionally, it uses PhotoBox Lightbox for image pop-ups. For styling, it imports various CSS files, including Bootstrap and Animate.css. After setting up the scripts and styles, the function requires the ‘album-gallery-output.php’ file to generate the gallery’s HTML. The function uses output buffering to capture and return the generated HTML, ensuring it’s properly inserted into the post content.
Shortcode: [AGAL]
Examples and Usage
Basic example – Utilizing the shortcode to display an album gallery with a specific post ID.
[AGAL post_id=3 /]
Advanced examples
Using the shortcode to display an album gallery with multiple post IDs. The gallery will load images from multiple posts.
[AGAL post_id="3,5,8" /]
Using the shortcode to display an album gallery with a specific post ID and applying a specific CSS class to the gallery for custom styling.
[AGAL post_id=3 class="my-custom-class" /]
Please note, the actual functionality of these shortcode examples depends on how the ‘nag_album_gallery_shortcode’ function is defined and how it handles the ‘post_id’ and ‘class’ attributes. If the function doesn’t support these attributes, the shortcode examples will not work as expected.
PHP Function Code
In case you have difficulties debugging what causing issues with [AGAL]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'AGAL', 'nag_album_gallery_shortcode' );
Shortcode PHP function:
function nag_album_gallery_shortcode( $post_id ) {
ob_start();
// js
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'nag-isotope-js' );
wp_enqueue_script( 'nag-imagesloaded-js' );
// PhotoBox Lightbox
wp_enqueue_style( 'nag-photobox-css' );
wp_enqueue_script( 'nag-photobox-js' );
// css
wp_enqueue_style( 'nag-bootstrap-css' );
wp_enqueue_style( 'nag-animate-css' );
wp_enqueue_style( 'nag-hover-stack-style-css' );
wp_enqueue_style( 'nag-hover-overlay-effects-css' );
wp_enqueue_style( 'nag-hover-overlay-effects-style-css' );
// output code file
require 'include/album-gallery-output.php';
wp_reset_query();
return ob_get_clean();
}
Code file location:
new-album-gallery/new-album-gallery/shortcode.php
Conclusion
Now that you’ve learned how to embed the Album Gallery – WordPress 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