Below, you’ll find a detailed guide on how to add the 3d Flipbook Dflip Lite 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 3d Flipbook Dflip Lite Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the 3d Flipbook Dflip Lite Plugin and the shortcodes it provides:
"PDF Flipbook, 3D Flipbook WordPress – DearFlip is an innovative plugin that transforms your PDFs into interactive 3D flipbooks. Ideal for digital magazines, catalogs, and brochures."
- [dflip]
3d Flipbook Dflip Lite [dflip] Shortcode
The 3D Flipbook DFlip Lite plugin shortcode is used to generate a 3D flipbook on your WordPress site. It allows the display of single or multiple books. It uses the ‘dflip’ shortcode to fetch the book(s) by their ID(s) or category. If ‘all’ or ‘*’ is used, it fetches all the books. The ‘limit’ attribute restricts the number of books displayed. The output is a neatly styled div containing your 3D flipbooks.
Shortcode: [dflip]
Parameters
Here is a list of all possible dflip shortcode parameters and attributes:
id
– unique identifier of the flipbookclass
– CSS class for styling the flipbookbooks
– list of flipbook IDs or categories to displaylimit
– maximum number of flipbooks to show
Examples and Usage
Basic example – A simple usage of the dflip shortcode to display a single book using its ID.
[dflip id="1" /]
Advanced examples
Display multiple books by specifying their IDs in the books attribute. The limit parameter can be used to restrict the number of books displayed.
[dflip books="1,2,3" limit="2" /]
Display all the books from a specific category. In this case, the category is identified by its slug. The limit parameter is set to -1, which means there is no limit on the number of books displayed.
[dflip books="category_slug" limit="-1" /]
Display all the books excluding certain IDs. The limit parameter is set to -1, which means there is no limit on the number of books displayed.
[dflip books="all" limit="-1" exclude="1,2" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [dflip]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'dflip', array( $this, 'shortcode' ) );
Shortcode PHP function:
function shortcode( $attr, $content = '' ) {
$ismulti = isset( $attr['books'] ) && trim( $attr['books'] ) !== '';
$atts_default = array(
'class' => '',
'id' => '',
'books' => ''
);
//atts or post defaults
$atts = shortcode_atts( $atts_default, $attr, 'dflip' );
if ( $ismulti ) {
$limit = isset( $attr['limit'] ) ? (int) $attr['limit'] : 5;
$ids = array();
$books = explode( ',', $atts['books'] );
foreach ( (array) $books as $query ) {
$query = trim( $query );
if ( is_numeric( $query ) ) {
array_push( $ids, $query );
} else {
if ( $query == 'all' || $query == '*' ) {
$postslist = get_posts( array(
'post_type' => 'dflip',
'posts_per_page' => - 1,
'numberposts' => $limit,
'nopaging' => true,
'exclude' => $ids
) );
foreach ( $postslist as $post ) {
array_push( $ids, $post->ID );
}
} else {
$postslist = get_posts( array(
'tax_query' => array(
array(
'taxonomy' => 'dflip_category',
'field' => 'slug',
'terms' => $query,
)
),
'post_type' => 'dflip',
'posts_per_page' => - 1,
'numberposts' => $limit,
'nopaging' => true,
'exclude' => $ids
) );
foreach ( $postslist as $post ) {
array_push( $ids, $post->ID );
}
}
}
}
$html = '<div class="dflip-books">';
$limitMax = $limit == '-1' ? 999 : (int) $limit;
$limit = 0;
foreach ( $ids as $id ) {
if ( $limit >= $limitMax ) {
break;
}
$attr['id'] = esc_attr( $id );
$html .= $this->book( $attr, $content, true );
$limit ++;
}
return $html . '</div>';
} else {
return $this->book( $attr, $content );
}
}
Code file location:
3d-flipbook-dflip-lite/3d-flipbook-dflip-lite/inc/shortcode.php
Conclusion
Now that you’ve learned how to embed the 3d Flipbook Dflip Lite 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