つい先日に質問し、miz様よりご回答を頂いたものです。(有難うございました。)
ご回答を元に、やりくりすれば「カテゴリーに説明文付きの画像を何枚も表示させたい。」を実現出来ると思っておりましたが、まったくチンプンカンプンで上手くいかなかったので再度質問させて下さい。
まず、画像だけの出力は、miz様のご回答そのままでうまく表示できましたが、画像のサイズが「フィールド編集内のプレビューサイズ」を変更してもimg width="150" height="150"で出力されてしまう(ソースで確認)のです。サイズの指定方法が分かりません。
画像のサイズ変更も出来ていないのですが、フィールド編集画面でサブフィールドを追加しテキストにて画像の説明分を付けたいと思っております。
正直、PHPをなめていました。htmlを少しかじったくらいでは太刀打ち出来ないと分かり、恥ずかしながら再度質問と言うか、解決策をご教授して頂けたらと思います。
宜しくお願い致します。
発生している問題・エラーメッセージ
サイズを変更しても下記ソースで出力されてしまいます。⇓
<img width="150" height="150" src="http://amami-setouti.com/wp/wp-content/uploads/s-P1150005-150x150.jpg" class="attachment-thumbnail size-thumbnail" alt="たんかん4" /><img width="150" height="150" src="http://amami-setouti.com/wp/wp-content/uploads/s-P1150013-150x150.jpg" class="attachment-thumbnail size-thumbnail" alt="たんかん5" /> </div>
該当のソースコード
miz様よりご回答頂いたソースコード↓
<?php $term_id = get_query_var('cat'); $objects = SCF::get_term_meta( $term_id, 'category', '商品紹介' ); foreach ( $objects as $object ) { echo wp_get_attachment_image( $object['scfimg'] ); } ?>
補足情報(言語/FW/ツール等のバージョンなど)
wordpressバージョン → WordPress 4.7.1
テーマ → WelcartBasicの子テーマ Welcart Nova
Smart Custom Fieldsの
フィールド名 → ギャラリー
グループ名 → 商品紹介
タイプ → 画像
名前 → scfimg
ラベル → scfimg
サブフィールドの
タイプ → テキスト
名前 → txt
ラベル → txt
Welcart Nova: カテゴリーテンプレート (category.php)
の中身です。
現在は</div><!-- #content -->の上に画像出力させています。
<?php /** * @package Welcart * @subpackage Welcart_Basic */ get_header();?> <div id="primary" class="site-content"> <?php $term_img = $term_class = $term_before = $term_after = ''; $term_id = get_query_var( 'cat' ); $term_img_url = get_term_meta( $term_id, 'wcct-tag-thumbnail-url', true ); if( ! empty( $term_img_url ) ) { $term_img = '<p class="taxonomy-img"><img src="' . get_term_meta( $term_id, 'wcct-tag-thumbnail-url', true ) . '"></p>'; } if( wcct_get_options( 'cat_image' ) && ! empty( $term_img_url ) ) { $term_class = ' over'; $term_before = '<div class="wrap"><div class="inner">'; $term_after = '</div></div>'; } ?> <div class="page-header<?php echo $term_class; ?>"> <?php echo $term_img; echo $term_before; the_archive_title( '<h1 class="page-title">', '</h1>' ); the_archive_description( '<div class="taxonomy-description">', '</div>' ); echo $term_after; ?> </div><!-- .page-header --> <div class="content-wrapper"> <div id="content" role="main"> <?php if( usces_is_cat_of_item( $term_id ) ): ?> <?php if (have_posts()) : ?> <div class="cat-il type-grid"> <?php while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>"> <div class="itemimg"> <a href="<?php the_permalink(); ?>"> <?php usces_the_itemImage( 0, 300, 300 ); ?> <?php if( wcct_get_options( 'display_soldout' ) && ! usces_have_zaiko_anyone() ): ?> <div class="itemsoldout"> <div class="inner"> <?php _e('SOLD OUT', 'welcart_basic_nova' ); ?> <?php if( wcct_get_options( 'display_inquiry' ) ): ?> <span class="text"><?php wcct_options( 'display_inquiry_text' ); ?></span> <?php endif; ?> </div> </div> <?php endif; ?> </a> </div> <?php wcct_produt_tag(); ?> <?php welcart_basic_campaign_message(); ?> <div class="item-info-wrap"> <div class="itemname"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php usces_the_itemName(); ?></a></div> <div class="itemprice"><?php usces_crform( usces_the_firstPrice('return'), true, false ) . usces_guid_tax(); ?></div> </div><!-- item-info-box --> </article> <?php endwhile; ?> </div><!-- .cat-il --> <?php else: ?> <p class="no-date"><?php echo __('No posts found.', 'usces'); ?></p> <?php endif; ?> <?php else : ?> <?php if (have_posts()) : ?> <div class="post-li"> <?php while (have_posts()) : the_post(); ?> <article id="post-<?php the_ID(); ?>"> <?php if ( has_post_thumbnail() ): ?> <div class="thumb-img"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a></div> <?php endif; ?> <p><time datetime="<?php the_time('c'); ?>"><?php the_time(__('Y/m/d')) ?></time></p> <div class="post-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf( esc_attr__( 'Permalink to %s', 'welcart_basic' ), the_title_attribute( 'echo=0' ) ); ?>"><?php the_title(); ?></a></div> <?php the_excerpt() ?> </article> <?php endwhile; ?> </div> <?php else: ?> <p class="no-date"><?php echo __('No posts found.', 'usces'); ?></p> <?php endif; ?> <?php endif; ?> <div class="pagination_wrapper"> <?php $args = array ( 'type' => 'list', 'prev_text' => __( ' « ', 'welcart_basic' ), 'next_text' => __( ' » ', 'welcart_basic' ), ); echo paginate_links( $args ); ?> </div><!-- .pagenation-wrapper --> <?php $term_id = get_query_var('cat'); $objects = SCF::get_term_meta( $term_id, 'category', '商品紹介' ); foreach ( $objects as $object ) { echo wp_get_attachment_image( $object['scfimg'] ); } ?> </div><!-- #content --> <?php get_sidebar(); ?> </div><!-- .content-wrapper --> </div><!-- #primary --> <?php get_footer(); ?>
カテゴリーページのhttpアドレスです。
回答1件
あなたの回答
tips
プレビュー