ショートコードの書き方
-
<ul class=" center-block clearfix"> <?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('post_type=therapists' . '&paged=' . $paged . '&posts_per_page=99'); ?> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <?php $images = get_post_meta($post->ID, 'myupload_images' ,true); ?> <?php $thrapist_src = wp_get_attachment_image_src ($images[0], 'therapistlist_thum'); ?> <li> <div class="detail "> <a href="<?php the_permalink(); ?>"><img src="<?php echo $thrapist_src[0]; ?>"></a> <div class="therapist_detail"> <h4><?php the_title(); ?><small>(<?php echo get_post_meta($post->ID , 'am-age' ,true); ?>歳)</small></h4> <p>身長<?php echo get_post_meta($post->ID , 'am-height' ,true); ?> B<?php echo get_post_meta($post->ID , 'am-bust' ,true); ?>(<?php echo get_post_meta($post->ID , 'am-cup' ,true); ?>) / W<?php echo get_post_meta($post->ID , 'am-waist' ,true); ?> / H<?php echo get_post_meta($post->ID , 'am-hip' ,true); ?></p> <?php if( get_field('micchaku') ){ ?> <!--真の場合の処理--> <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/btn_michaku.png" alt="密着マッサージ対応" /> <?php }else{ ?> <!--偽の場合の処理--> <?php } ?> <?php if( get_field('newcommer') ){ ?> <!--真の場合の処理--> <img src="<?php echo get_stylesheet_directory_uri(); ?>/images/btn_new.png" alt="新人" /> <?php }else{ ?> <!--偽の場合の処理--> <?php } ?> </div> </div> </li> <?php endwhile; ?> </ul>
こちらのコードをショートコード化して以下のように書いたのですが、エラーはないもの一部表示されないままです。
正しい書き方をおしえてください
よろしくお願いしますfunction getcastList($atts){ $content.='<ul class=" center-block clearfix">'; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('post_type=therapists' . '&paged=' . $paged . '&posts_per_page=99'); while ( $wp_query->have_posts() ) : $wp_query->the_post(); $images = get_post_meta($post->ID, 'myupload_images' ,true), $thrapist_src = wp_get_attachment_image_src ($images[0], 'therapistlist_thum') $content.='<li><div class="detail "><a href="'. get_the_permalink() .'"><img src="'. $thrapist_src[0] .'"></a><div class="therapist_detail"><h4>'. get_the_title() .'<small>('. get_post_meta($post->ID , 'am-age' ,true) .'歳)</small></h4><p>身長'. get_post_meta($post->ID , 'am-height' ,true) .' B'. get_post_meta($post->ID , 'am-bust' ,true) .'('. get_post_meta($post->ID , 'am-cup' ,true) .') / W'. get_post_meta($post->ID , 'am-waist' ,true) .' / H'. get_post_meta($post->ID , 'am-hip' ,true) .'</p>'; if( get_field('micchaku') ){ //真の場合の処理 $content.='<img src="'. get_stylesheet_directory_uri() .'/images/btn_michaku.png" alt="密着マッサージ対応" />'; }else{ //偽の場合の処理 }; if( get_field('newcommer') ){ //真の場合の処理 $content.='<img src="'. get_stylesheet_directory_uri() .'/images/btn_new.png" alt="新人" />'; }else{ //偽の場合の処理 }; $content.=' </div> </div> </li> '; endwhile; $content.='</ul>'; return $content; } add_shortcode('castlist','getcastList');
- トピック「ショートコードの書き方」には新たに返信することはできません。