WordPress Books Gallery Shortcode

Below, you’ll find a detailed guide on how to add the WordPress Books 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 WordPress Books Gallery Plugin shortcode not to show or not to work correctly.

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

Plugin Icon
WordPress Books Gallery

"WordPress Books Gallery is a useful plugin that transforms your WordPress site into an interactive bookshelf, offering a visually appealing display for your eBook collections or libraries."

★★★★☆ (65) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [wp_books_gallery]

WordPress Books Gallery [wp_books_gallery] Shortcode

The wp_books_gallery shortcode is designed to display a gallery of books on your WordPress site. It fetches the gallery settings, styles, search content, search styling, and core settings to create a customized book gallery. This shortcode generates an output after processing the settings and includes the gallery view from the ‘front/view/gallery.php’ file. It offers flexibility in terms of pagination and styling.

Shortcode: [wp_books_gallery]

Examples and Usage

Basic example – Displaying a basic book gallery using the shortcode

[wp_books_gallery /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'wp_books_gallery', array( $this, 'wbg_load_shortcode_view' ) );

Shortcode PHP function:

function wbg_load_shortcode_view( $attr )
    {
        global  $wpdb, $post ;
        // Gallery Content
        $wpsdGallerySettingsContent = $this->wbg_get_gallery_settings_content();
        foreach ( $wpsdGallerySettingsContent as $gscKey => $gscValue ) {
            if ( isset( $wpsdGallerySettingsContent[$gscKey] ) ) {
                ${"" . $gscKey} = $gscValue;
            }
        }
        //$wbg_books_per_page = $wbg_books_per_page_np;
        $wbg_display_pagination = $wbg_display_pagination_np;
        // Gallery Styles
        $wpsdGallerySettingsStyles = $this->wbg_get_gallery_styles_settings();
        foreach ( $wpsdGallerySettingsStyles as $gssKey => $gssValue ) {
            if ( isset( $wpsdGallerySettingsStyles[$gssKey] ) ) {
                ${"" . $gssKey} = $gssValue;
            }
        }
        // Search Content
        $wbgSearchContent = $this->wbg_get_search_content_settings();
        foreach ( $wbgSearchContent as $sc_name => $sc_value ) {
            if ( isset( $wbgSearchContent[$sc_name] ) ) {
                ${"" . $sc_name} = $sc_value;
            }
        }
        // Search Styling
        $wbgSearchStyles = $this->wbg_get_search_styles_settings();
        foreach ( $wbgSearchStyles as $ss_name => $ss_value ) {
            if ( isset( $wbgSearchStyles[$ss_name] ) ) {
                ${"" . $ss_name} = $ss_value;
            }
        }
        // General Settings
        $wbgCoreSettings = $this->wbg_get_core_settings();
        foreach ( $wbgCoreSettings as $core_name => $core_value ) {
            if ( isset( $wbgCoreSettings[$core_name] ) ) {
                ${"" . $core_name} = $core_value;
            }
        }
        $output = '';
        ob_start();
        include WBG_PATH . 'front/view/gallery.php';
        $output .= ob_get_clean();
        return $output;
    }

Code file location:

wp-books-gallery/wp-books-gallery/front/cls-books-gallery-front.php

Conclusion

Now that you’ve learned how to embed the WordPress Books 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.

Comments

Leave a Reply

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