【问题标题】:Add real="pretyphoto" to wordpress gallery image将 real="pretyphoto" 添加到 wordpress 图库图片
【发布时间】:2015-02-15 13:00:03
【问题描述】:

我已经在我的主题中使用 Pretyphoto 脚本在漂亮的灯箱中打开精选图片。

现在我想将 rel="pretyphoto" 添加到 wordpress 图库图片 我不能手动操作,因为我需要编辑 media.php 核心文件

所以我想使用一个可以完成这项工作的函数。

我已经在这里找到了 cmets 的解决方案:

function add_nofollow_to_comments_popup_link() {
return ' rel="nofollow" ';
}
add_filter( 'comments_popup_link_attributes', 'add_nofollow_to_comments_popup_link' );

所以我需要类似的东西来制作 wordpress 的图库图片。

谢谢

【问题讨论】:

    标签: gallery prettyphoto


    【解决方案1】:

    自己找到答案:

    这里是任何有兴趣的人的解决方案。 在你的主题functions.php中添加这段代码

    add_filter( 'wp_get_attachment_link', 'sant_prettyadd');
    
    function sant_prettyadd ($content) {
    $content = preg_replace("/<a/","<a rel=\"prettyPhoto[slides]\"",$content,1);
    return $content;
    }
    

    并且图库附件必须是媒体文件

    【讨论】:

      猜你喜欢
      • 2012-01-28
      • 1970-01-01
      • 2016-04-16
      • 2012-02-25
      • 1970-01-01
      • 2011-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多