Support » Plugin: WP-Blocks » [Plugin: WP-Blocks] Including a block in content via a shortcode

  • bigcalm

    (@bigcalm)


    function get_wp_block_shortcode( $atts ) {
        extract( shortcode_atts( array(
          'name' => '',
        ), $atts ) );
    
        global $wpdb;
        $block_slug = trim($name);
        $data = (array)$wpdb->get_row("SELECT * FROM {$wpdb->prefix}wpb_content WHERE name = '{$name}' AND active = TRUE");
        if($data) return get_wrapped_block_content($data);
      }
    
      add_shortcode('get_wp_block', 'get_wp_block_shortcode');

    In a post, page or other content area, use the shortcode [get_wp_block] to insert blocks where ever you need them.

    Example:
    [get_wp_block name="foo"]

    http://wordpress.org/extend/plugins/wp-blocks/

  • The topic ‘[Plugin: WP-Blocks] Including a block in content via a shortcode’ is closed to new replies.