3D FlipBook - call the plugin using do_shortcode

n***i@gmail.com
2023-06-04
2023-06-13

I appreciate the plugin for its versatility and currently using it on our web-site.

We have many books for our students and would like the student to select the required book and view. In a Wordpress page, the shortcode works perfectly. But when called through a php, it won't work.

Code:

<?php 
require_once( 'wp-includes/shortcodes.php' );
require_once( 'wp-includes/plugin.php' );
    $selected = $_POST['Books'];
    if(isset($_POST['submit'])){  
    if(!empty($_POST['Books'])) {  
        $selected = $_POST['Books'];  
        echo 'You have selected: ' . "$selected";
        $flipbook_popup = '[3d-flip-book id="'.$selected.'" ][/3d-flip-book]';
        echo $flipbook_popup."
"; //echo apply_filters( 'the_content',"[3d-flip-book id='$selected'][/3d-flip-book]"); echo "do_shortcode($flipbook_popup)"; } else { echo 'Please select the value.'; } } ?>

The Result: You have selected: 16[3d-flip-book id="16" ][/3d-flip-book] do_shortcode([3d-flip-book id="16" ][/3d-flip-book])

Where I'm going wrong? Please help.

Replies

a***r@3dflipbook.net
2023-06-13
2023-06-13

Probably you need to replace

echo "do_shortcode($flipbook_popup)";

with

echo do_shortcode($flipbook_popup);
n***i@gmail.com
2023-06-13
2023-06-13

I have tried that, it is just reloading the page and gives Error 404 - file not found

Is there a way to pass the selected value into the shortcode section in Wordpress page? I have added a block "shortcode" in Wordpress page and placed this code. [3d-flip-book id=wp_cache_get('selvalue')][/3d-flip-book] Tried php echo as well. What would be the correct format.

n***i@gmail.com
2023-06-24
2023-06-24

<?php require_once( 'wp-includes/shortcodes.php' ); require_once( 'wp-includes/plugin.php' ); $retvalue ='do_shortcode([3d-flip-book id="24"][/3d-flip-book])'; return $retvalue ; / if( shortcode_exists( '3d-flip-book' ) ) do_shortcode('[3d-flip-book id="24"][/3d-flip-book]'); else echo "The shortcode 3d-flip-book is not installed."; / ?>

Log In to leave a comment