PHP内で変数を使う
-
<?php if(get_post_meta($post->ID, '変数1', true)): ?> <?php $imagefield = get_imagefield('変数1'); $attachment = get_attachment_object($imagefield['id']); echo '<p><a href="変数2"><img src="' . $attachment['url'] . '" alt="' . $attachment['title'] . '" title="' . $attachment['content'] . '" width="300" height="30" /></a></p>'; ?> <?php endif; ?>
カスタムフィールドで【変数1】という画像に【変数2】というリンクを付けたいのですがどうもうまくいきません。
<?php if(get_post_meta($post->ID, '変数1', true)): ?> <?php $リンクURL = get_post_custom('変数2'); $imagefield = get_imagefield('変数1'); $attachment = get_attachment_object($imagefield['id']); echo '<p><a href="変数2"><img src="' . $attachment['url'] . '" alt="' . $attachment['title'] . '" title="' . $attachment['content'] . '" width="300" height="30" /></a></p>'; ?> <?php endif; ?>
上記の様に書くとそのまま【変数2】という値が返されてしまいます。
ご教授頂ければ幸いです。
4件の返信を表示中 - 1 - 4件目 (全4件中)
4件の返信を表示中 - 1 - 4件目 (全4件中)
- トピック「PHP内で変数を使う」には新たに返信することはできません。