カスタム投稿の記事を表示するウィジェットでカスタムフィールドを表示
-
http://minaichi.pecori.jp/blog/335.html
こちらの記事を参考にカスタム投稿の記事を表示するウィジェットを作成致しました。
ウィジェットではない通常のポストではget_post_metaでカスタムフィールドの値を表示できてるのですが、ウィジェット側でのカスタムフィールドが表示がうまくいかず困っております。
post_typeは間違っていません。get_post_custom_valueなども試してみましたがそちらでは「array」と配列が出力されてるようです。
変数に含ませずに出力もしてみましたが表示されず、困っております。ご教授頂ければ幸いです。よろしく御願い致します。
$infolist = new wp_query( array( 'post_type'=>$post_type, 'post_status'=>'publish', 'posts_per_page'=>1, 'order'=>'DESC', 'orderby'=>'date') ); if ($infolist->have_posts()) : ?> <ul class="widget_body original_info_body"> <?php while ($infolist->have_posts()) { $infolist->the_post(); $list = "<li>"; $list .= "<div class=\"title\">" . get_the_title() . "</div>"; $list .= "<p>" . get_post_meta($post->ID , 'field' ,true) . "</p>"; $list .= "</li>\n"; echo $list; } ?> </ul> <?php echo get_post_meta($post->ID , 'field' ,true); ?> <?php endif; wp_reset_query(); ?>
1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
- トピック「カスタム投稿の記事を表示するウィジェットでカスタムフィールドを表示」には新たに返信することはできません。