【问题标题】:WPBakery Grid builder get post contentWPBakery Grid builder 获取帖子内容
【发布时间】:2020-07-30 21:14:36
【问题描述】:

我正在尝试在 WpBakerys Grid builder 中显示 Post 的全部内容

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

简而言之,我怎样才能显示完整的帖子内容而不是摘录?

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    您可以向 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-10
      • 1970-01-01
      • 2019-01-15
      相关资源
      最近更新 更多