フォーラムへの返信

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック投稿者 33W5IaV0

    (@33w5iav0)

    imgタグで入っていたので、PHPでaタグに書き換えました。
    下記のコードでテキストリンクに変更できました。

    <?php function imgLink($html){
    	preg_match_all('/<img(.+?)>/', $html, $match);
    	for($i=0;$i<count($match[0]);$i++){
    		preg_match('(http:\/\/[a-z0-9/\-_.]+)',$match[0][$i],$url_match);
    		$url_link = '[<a href="'.$url_match[0].'">画像</a>]';
    		$html= str_replace($match[0][$i],$url_link,$html);
    	}
    	echo $html;
    } ?>
    <?php $post = get_post($post_id); imgLink(get_post_meta($post->ID, $key, true)); ?>

    ありがとうございました。

    トピック投稿者 33W5IaV0

    (@33w5iav0)

    ありがとうございます。

    現在テンプレートは、

    <?php $post = get_post($post_id); echo get_post_meta($post->ID, '$key,', true); ?>

    というコードになっていますが、どのように変更したらよいでしょうか?

2件の返信を表示中 - 1 - 2件目 (全2件中)