Skip to content

Instantly share code, notes, and snippets.

@pavelthq
Last active September 26, 2017 08:13

Revisions

  1. pavelthq revised this gist Feb 16, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion attribute.php
    Original file line number Diff line number Diff line change
    @@ -12,7 +12,7 @@ function vc_gitem_template_attribute_post_custom_meta( $value, $data ) {
    $atts_extended = array();
    parse_str( $data, $atts_extended );

    $atts = $atts_exntended['atts'];
    $atts = $atts_extended['atts'];
    $output = print_r($atts, true); // will containt shortcode ATTS
    $output .= print_r($post->ID, true); // will contain current POST_ID
    $output .= print_r(get_post_meta($post->ID), true); // will contain current post meta..
  2. pavelthq created this gist Feb 16, 2016.
    20 changes: 20 additions & 0 deletions attribute.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    add_filter( 'vc_gitem_template_attribute_post_custom_meta', 'vc_gitem_template_attribute_post_custom_meta', 10, 2 );

    function vc_gitem_template_attribute_post_custom_meta( $value, $data ) {
    /**
    * @var null|Wp_Post $post ;
    * @var string $data ;
    */
    extract( array_merge( array(
    'post' => null,
    'data' => '',
    ), $data ) );
    $atts_extended = array();
    parse_str( $data, $atts_extended );

    $atts = $atts_exntended['atts'];
    $output = print_r($atts, true); // will containt shortcode ATTS
    $output .= print_r($post->ID, true); // will contain current POST_ID
    $output .= print_r(get_post_meta($post->ID), true); // will contain current post meta..
    return $output;
    }
    20 changes: 20 additions & 0 deletions init.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    add_filter( 'vc_grid_item_shortcodes', 'my_module_add_grid_shortcodes' );
    function my_module_add_grid_shortcodes( $shortcodes ) {
    $shortcodes['vc_say_hello'] = array(
    'name' => __( 'Say Hello', 'my-text-domain' ),
    'base' => 'vc_say_hello',
    'category' => __( 'Content', 'my-text-domain' ),
    'description' => __( 'Just outputs Hello World', 'my-text-domain' ),
    'post_type' => Vc_Grid_Item_Editor::postType(),
    );
    return $shortcodes;
    }

    add_shortcode( 'vc_say_hello', 'vc_say_hello_render' );
    function vc_say_hello_render($atts){
    /** @var $atts array - shortcode attributes */
    $atts = vc_map_get_attributes( 'vc_say_hello', $atts );
    return '{{ post_custom_meta:' . http_build_query( array(
    'atts' => $atts,
    ) ) . '}}';
    }