WPBakery Grid构建器获取帖子内容

时间:2018-07-02 11:50:09

标签: wordpress

我正在尝试在WpBakerys网格构建器中显示Post的全部内容

我只能添加帖子摘录,但我想添加完整内容,而不是摘要。我看到可以添加自定义字段,但不知道帖子内容的字段键名称。

简而言之,我如何显示完整的帖子内容而不是摘录?

1 个答案:

答案 0 :(得分:0)

您可以将自定义的简码添加到Grid Builder:

add_filter( 'vc_grid_item_shortcodes', 'my_module_add_grid_shortcodes' );
function my_module_add_grid_shortcodes( $shortcodes ) {
    $shortcodes['vc_post_content'] = array(
        'name' => __( 'Post Content', 'my-text-domain' ),
        'base' => 'vc_post_content',
        'category' => __( 'Content', 'my-text-domain' ),
        'description' => __( 'Show current post content', 'my-text-domain' ),
        'post_type' => Vc_Grid_Item_Editor::postType(),
    );
    return $shortcodes;
}

// output function
add_shortcode( 'vc_post_content', 'vc_post_content_render' );
function vc_post_content_render() {
    return '<p>{{ post_data:post_content }}</p>'; // usage of template variable post_data with argument "post_content"
}

来源:https://kb.wpbakery.com/docs/developers-how-tos/adding-custom-shortcode-to-grid-builder/#AddingCustomShortcodetoGridBuilder-Templatevariablesusage