wordpress - WPBakery 网格构建器获取帖子内容

标签 wordpress

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

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

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

最佳答案

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

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

关于wordpress - WPBakery 网格构建器获取帖子内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51135530/

相关文章:

css - 在 css 中替换 @import 的谷歌字体

php - 投资组合类别 - 如何更改它们在投资组合页面(WordPress 网站)上的显示顺序

php - 在 Woocommerce 中获取订单标题

performance - 优化图像沉重WordPress博客的速度

php - 上游从上游读取响应 header 时发送了太大的 header

html - Wordpress 在 header 中的动态 css 样式标签中输出多个 body css 样式

wordpress - 限制 WordPress 搜索结果项

php - WordPress 编码标准 – phpcs 警告

ios - 检查 WebView 中的 URL 是否已更改?

jquery - Fancybox 导航箭头和关闭按钮没有透明悬停