首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WPBakery网格构建器获取post内容

WPBakery网格构建器获取post内容
EN

Stack Overflow用户
提问于 2018-07-02 11:50:09
回答 1查看 2.7K关注 0票数 2

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

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

总之,我怎么才能显示完整的帖子内容而不是摘录呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-07 07:18:22

可以向“网格生成器”中添加自定义短代码:

代码语言:javascript
复制
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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51135530

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档