プラグインを使わずにCategoryページで単一記事の投稿内にある外部画像のUR
-
WordPressをご支援されている皆様。
お世話になっております。投稿記事(single.php)の中に表示させている外部画像(直リンク専用のバナー等)を、category.phpやtag.php等で、一覧表示させる際に、画像をサムネイル化してリンクとシングルページへのリンクと一緒にリスト表示したいと考えております。
http://ja.forums.wordpress.org/topic/3134?replies=12
http://ja.forums.wordpress.org/topic/4806?replies=10
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
http://ja.forums.wordpress.org/topic/4827?replies=5<?php foreach($posts as $post): setup_postdata($post); ?> <h3> <?php $dat = get_posts('post_type=attachment&orderby=menu_order&order=ASC&numberposts=1&post_parent='.get_the_ID()); if (count($dat)> 0) { $image = wp_get_attachment_image_src($dat[0]->ID); $desc = '<img src="'.$image[0].'" width="100px" height="100px" alt="" /></a>'; // 記事出力 echo '<a href="' . get_permalink() . '" title="' . the_title('', '', false) . '">'; echo $desc;} ?> <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> :: <?php the_time('Y年n月'); ?></h3> <?php endforeach; ?>
上記のサイトを参考に、カスタマイズしているのですが、ページが真っ白になったり、HTMLに<img>コードがうまく挿入できなかったりしております。
単一記事に貼っている画像は、WordPressの管理画面にある「メディア」から登録したものではなく、直リンク専用のバナーや、別サーバーにある画像を直接「絶対パス」形式で呼び出しています。
なるべくCustom Field Template pluginなどのプラグインを使わないで、投稿記事内にある外部画像のURLを取得し、カテゴリーページ等でリスト表示させたいと考えております。
loop-category.phpを新規に作成し、ソースコードは下記のようになっております。(一部抜粋)
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h3 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h3> <div class="thumbnail-image"> ●●ここに外部URLの画像のサムネイルを表示したいと考えています。 </div> <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content"> <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?> </div><!-- .entry-content --> <?php endif; ?> <div class="entry-utility"> <?php if ( count( get_the_category() ) ) : ?> <p class="entry-content-category"><?php printf( __( 'Category : %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> </p> <?php endif; ?> <?php $tags_list = get_the_tag_list( '', ', ' ); if ( $tags_list ): ?> <p class="entry-content-tag"><?php printf( __( 'Tag : %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?> </p> <div class="entry-meta"> Date : <?php the_time('Y/m/d H:i:s', '', ''); ?> </div><!-- .entry-meta --> <?php endif; ?>
どなたか、解決策をご存じでしたら、ご伝授頂けますでしょうか。
御忙しい中、たいへんお手数ですが、どうぞよろしくお願い申し上げます。テーマは、 Twentytenを使用し、カスタマイズしております。
サーバーは、さくらのレンタルサーバー。
WordPressは最新バージョンを使用しております。
- トピック「プラグインを使わずにCategoryページで単一記事の投稿内にある外部画像のUR」には新たに返信することはできません。