Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Suggestion for custom Dynamic Tags and Element Hook

  • So I have couple of suggestions

    1. It will be nice if you can provide post ID to dynamic tag here https://prnt.sc/gw4Nh7Nzh6pF . So we can pass it to shortcode for example. I know I can get post ID from Post Permalink using url_to_postid(). But it will be nice if there is default support for it.
    2. Option for passing argument to custom hook created at Element. So when we call the hook manually using do_action(), we can for example passing the Post ID manually and use that ID instead of get_the_ID(). This will be usefull for combine it with FacetWP. Because do_action cannot recognize get_the_id() when performing ajax call when we filtering posts using FacetWP.

    Thank you.

  • Hi there,

    1. GB 2.0’s dynamic tags system is super flexible, you can create your own dynamic tag.

    Here’s the code to create a dynamic tag {{post_id}}:

    function yh_post_id( $options, $block, $instance ) {
            $output = get_the_ID();
        return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
    }
     
    add_action( 'init' , function () {
    
            new GenerateBlocks_Register_Dynamic_Tag(
                [
                    'title'       => __( 'Post Id', 'generateblocks' ),
                    'tag'         => 'post_id',
                    'type'        => 'Post',
                    'description' => __( "Get the ID of current post.", 'generateblocks' ),
                    'return'      => 'yh_post_id'
                ]
            );
    } );

    2. Not sure if it’s technically possible, but feel free to open a feature issue in GB’s Github.
    https://github.com/tomusborne/generateblocks/issues

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.