WordPress.org

Ready to get started?Download WordPress

Forums

WP-Blocks
Including a block in content via a shortcode (1 post)

  1. bigcalm
    Member
    Posted 3 years ago #

    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/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

  • RSS feed for this topic
  • Started 3 years ago by bigcalm
  • This topic is not a support question
  • WordPress version: 3.1

Tags