画像フォルダを新設する [WordPress]
固定ページ用の画像を1つ1つアップロードするのって、ちょっと面倒ですよね。
テーマの直下に任意のフォルダを作ってそこにゴーン!!
functionに
//画像フォルダ作成
function replaceImagePath($arg) {
$content = str_replace('"フォルダ名/', '"' . get_bloginfo('template_directory') . '/フォルダ名/', $arg);
return $content;
}
add_action('the_content', 'replaceImagePath');
htmlは
<img src="img/sample.jpg" alt="sample">
コメント 0