wordpressを少しいじった時のボツコード
これも自分用の投稿失礼します。
かなり久しぶりにwordpressいじりました。
サムネイル付きの記事一覧を出すだけなんですけど。
ショートコードとウィジェットの作り方も後から眺めてわかるかと。
function func_show_all_posts() { ?> <?php query_posts('posts_per_page=-1')?> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="block"> <div class="thums_title"> <a href="<?php the_permalink() ?>"><?php the_title(); ?> <span>(<?php the_time('Y/m/d'); ?>)</span> </a> </div> <div class="bg"> <?php the_excerpt(); ?> </div> </div> <?php endwhile; ?> <?php endif; ?> <?php wp_reset_query(); ?> <?php } add_shortcode('show_all_posts', 'func_show_all_posts'); class MyWidgetItem extends WP_Widget { function MyWidgetItem() { parent::WP_Widget(false, $name = '過去の記事一覧'); } function widget($args, $instance) { ?> <?php query_posts('posts_per_page=-1')?> <aside class="widget widget_show_all_posts"> <h3>記事一覧</h3> <?php func_show_all_posts(); ?> </aside> <?php } } add_action('widgets_init', create_function('', 'return register_widget("MyWidgetItem");')); function new_excerpt_mblength($length) { return 0; } add_filter('excerpt_mblength', 'new_excerpt_mblength'); function new_excerpt_more($more) { return ''; } add_filter('excerpt_more', 'new_excerpt_more');