【问题标题】:Simple lightbox wordpress plugin with wp_trim_words带有 wp_trim_words 的简单灯箱 wordpress 插件
【发布时间】:2014-03-28 01:25:20
【问题描述】:

我正在尝试将简单的灯箱插件与 wp_trim_words 函数结合起来。 the_content 要求存在问题,因此我无法让主页上的画廊正常工作。我得到了这个代码

$content = get_the_content();
        apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]>', $content);
        $trimmed_content = do_shortcode(wp_trim_words($content, 50, '<a href="' . get_permalink() . '" style="display: block; width: 100%;">...more</a>'));
        echo $trimmed_content;

它显示来自 [gallery=1,2,3] 的图像,但简单的灯箱插件未初始化。这里有什么问题?

【问题讨论】:

    标签: wordpress


    【解决方案1】:

    apply_filters() 返回数据。目前,您正在过滤$content,但不保存结果。

    // Before
    apply_filters('the_content', $content);
    
    // After
    $content = apply_filters('the_content', $content);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-11
      • 1970-01-01
      • 1970-01-01
      • 2018-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多