Book Slider Shortcode
This shortcode allows you to display a responsive slider or grid of books anywhere on your website. It supports various layouts, filtering options (by category, author, publisher), and customization settings.
Shortcode Name
[rswpbs_book_slider]
π How to Use
Basic Usage:
Simply paste this code into any page or post to display the default book slider.
Code snippet
[rswpbs_book_slider]
Advanced Usage (Example):
Here is an example showing specific books with a custom layout:
Code snippet
[rswpbs_book_slider books_per_page="10" slider_style="carousel" image_position="left" show_price="true" categories_include="5,8"]
βοΈ Attributes (Parameters)
You can customize the slider using the following attributes:
1. General Settings
| Attribute | Default | Accepted Values | Description |
slider_style | carousel | carousel, featured | Defines the layout style of the slider. |
books_per_page | 6 | Number, -1 (for all) | How many books to display total. Use -1 or unlimited to show all books. |
book_offset | '' (Empty) | Number | Number of books to skip from the beginning (useful for pagination). |
order | DESC | DESC, ASC | Sort order (Descending or Ascending). |
orderby | date | date, title, rand, price | Sort books by Date, Title, Random, or Price. |
2. Filtering (Query Control)
| Attribute | Default | Description |
categories_include | '' | Comma-separated Category IDs to show books from specific categories. |
categories_exclude | '' | Comma-separated Category IDs to hide books from specific categories. |
authors_include | '' | Comma-separated Author IDs (Taxonomy) to include. |
authors_exclude | '' | Comma-separated Author IDs to exclude. |
publishers_include | '' | Comma-separated Publisher Names to include. |
publishers_exclude | '' | Comma-separated Publisher Names to exclude. |
include_books | '' | Comma-separated Book Post IDs to show only specific books. |
exclude_books | '' | Comma-separated Book Post IDs to hide specific books. |
3. Layout & Design
| Attribute | Default | Accepted Values | Description |
image_position | top | top, left, right | Top: Standard Card view. Left/Right: List view (Image on side, content on other). |
content_align | center | center, left, right | Alignment of the text content inside the book card. |
sts_l_screen | 4 | Number | Number of items visible on Large Screens (Desktop). |
sts_m_screen | 3 | Number | Number of items visible on Medium Screens (Tablet). |
sts_s_screen | 1 | Number | Number of items visible on Small Screens (Mobile). |
4. Content Visibility
| Attribute | Default | Accepted Values | Description |
show_title | true | true, false | Show or hide the book title. |
title_type | book_name | book_name, default | book_name uses the custom book name field; default uses the WP Post Title. |
show_author | true | true, false | Show or hide the author name. |
show_image | true | true, false | Show or hide the book cover image. |
image_type | book_cover | book_cover, mockup_image | Switch between standard cover or 3D mockup (Pro feature). |
show_excerpt | true | true, false | Show or hide the short description. |
excerpt_type | excerpt | excerpt, fullcontent | Display the short excerpt or the full content. |
excerpt_limit | 60 | Number | Word limit for the excerpt. |
show_read_more_button | false | true, false | Show a “Read More” button linking to the book page. |
5. eCommerce & Buttons
| Attribute | Default | Accepted Values | Description |
show_price | true | true, false | Display the book price. |
show_buy_button | true | true, false | Display the external/affiliate buy button. |
show_add_to_cart_btn | true | true, false | Display WooCommerce “Add to Cart” button (Requires integration). |
show_msl | true | true, false | Show “Multiple Sales Links” (Pro feature). |
msl_title_align | center | center, left, right | Alignment of the Multiple Sales Links title. |
π Notes for Developers
- Backward Compatibility: The shortcode automatically converts old attributes (e.g.,
book_cover_positionβimage_position) so old shortcodes won’t break. - WooCommerce: If
rswpthemes_cptwoointegrationfunction exists, the “Add to Cart” functionality will work for direct sales. - Pro Features: Some features like
mockup_imageandshow_mslrequire the Pro version (Rswpbs_Proclass) to be active.
π‘ Usage Examples
Here are some common ways to use the shortcode with different configurations:
1. Standard Book Carousel
Display the latest 6 books in a default carousel slider.
Code snippet
[rswpbs_book_slider books_per_page="6" slider_style="carousel"]
2. List View (Image on Left)
Great for displaying detailed book reviews. This moves the book cover to the left and text to the right.
Code snippet
[rswpbs_book_slider image_position="left" content_align="left" show_excerpt="true" excerpt_limit="40"]
3. Specific Genre/Category Slider
Display books only from specific categories (e.g., “Fiction” or “Adventure”). Replace 10,12 with your category IDs.
Code snippet
[rswpbs_book_slider categories_include="10,12" books_per_page="8" show_price="true"]
4. Best Selling / Price Sorted
Show books sorted by price (High to Low) and display the “Add to Cart” button for direct sales.
Code snippet
[rswpbs_book_slider orderby="price" order="DESC" show_add_to_cart_btn="true" show_price="true"]
5. Minimalist Grid (Covers Only)
A clean look that hides the author, excerpt, and priceβshowing only the cover and title. Perfect for a sidebar or footer.
Code snippet
[rswpbs_book_slider show_author="false" show_excerpt="false" show_price="false" show_buy_button="false" sts_l_screen="5"]
Was this article helpful?