I'm building a website pro-bono for a friend searcher and making a template for 280 pages which will have the same structure as we want to be able to modify it in 1 place.

I do this with elementor template builder. In this template, I query several blocs of grid contents from different post types and it will display them depending on a common category.

For CPT, it's easy. I shared the native post category with ACF into the Page Type + into all my CPT, then I query dynamically the id into the post grids with Crocoblocks plugin.

The logic is id of the page = id of the posts/custom posts

But, I have a pdf flipbook plugin Dearflip which has already a shortcode to display a nice grid and I don't want to loose its functions like opening the flipbook in a modal. It's a CPT with posts and categories.

I don't code myself, so I'd be happy if you can help me.

1/ I need dflip_category from this plugin to share the same post category terms like the others CPT so my page category checked can show the right contents dynamically.

2/ I need to find a way to put the shortcode in the template with a dynamic id coming from the page category as it will be the same id. So I'm looking for a way to inject the page id dynamically into the shortcode.

The shortcode grid is like this [dflip books="slug"] and I'd like something like this [dflip books="{insert_page_category_slug}"] [/dflip]

Any help with the correct code would be awesome! I've been searching everywhere how to do it. It's out of my league.

Dearflip plugin CPT name : dflip taxonomy: dflip_category my Page (ACF) taxonomy : cat_id

Thanks in advance if anyone can help.

1 Answer 1


The solution for now is : create a plugin re-creating the shortcode with the current page slug. Naming the page slug like the category slug. And manually add the category to dflip.

Couldn't find better so far.

// Disable direct access
defined('ABSPATH') or die('No script kiddies please!');

// use page slug to call dflip book in same slug dflip_category
add_shortcode('dflip_book_slug', 'shortcode_dflip_book_slug');
function shortcode_dflip_book_slug($atts = array(), $content = '', $tag)
    global $post;

    // default parameters (but filtered, only declared ones are passed)
    // $atts = shortcode_atts(array(
    //   'books' => $post->post_name
    // ), $atts, $tag);

    $atts = is_array($atts) ? $atts : array();

    if (array_key_exists('books', $atts)) {
        $atts['books'] = str_replace('%slug%', $post->post_name, $atts['books']);
    } else {
        // par défaut on passe le slug
        $atts['books'] = $post->post_name;

    $atts_str = array();
    foreach ($atts as $key => $value) {
        $atts_str[] = $key . '="' . str_replace('"', '\"', $value) . '"';

    $shortcode = '[dflip ' . implode(' ', $atts_str) . ']' . $content . '[/dflip]';
    return do_shortcode($shortcode);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.