2012年6月4日月曜日

prettyphoto用のrelタグを自動で付与する

WordPressで画像に自動的にprettyphoto用のrelタグを付与する方法です。 プラグインを使えば簡単にできると思いますが、使わずにfunctions.phpに以下を追加することで実現しました。
function yk_add_prettyphoto_rel($content) {
    global $post;

    $pattern = "//i";
    $replacement = '';
    $content = preg_replace($pattern, $replacement, $content);
    $content = str_replace("%LIGHTID%", $post->ID, $content);

    return $content;
}
add_filter('the_content', 'yk_add_prettyphoto_rel');

0 件のコメント:

コメントを投稿