WP Nivo Slider
WP Nivo Slider
- スライドショーのような形で表示するプラグイン
作動させるためのコードを取得
- http://wordpress.org/extend/plugins/wp-nivo-slider/
- メニュータブの「Installation」をクリック
- http://wordpress.org/extend/plugins/wp-nivo-slider/installation/ の 「Installation」で以下をコピー
<?php if ( function_exists('show_nivo_slider') ) { show_nivo_slider(); } ?>
Twenty Eleven の場合
- 「header.php」でヘッダー画像の領域を削除します
<?php // Check to see if the header image has been removed $header_image = get_header_image(); …略… <?php get_search_form(); ?> <?php endif; ?>
- コピーした部分を「<div id="main">」の上に貼り付けます
…略… </header><!-- #branding --> <?php if ( function_exists('show_nivo_slider') ) { show_nivo_slider(); } ?> <div id="main">
CSSで微調整
/* =WP Nivo Slider ----------------------------------------------- */ .slider-wrapper { width:1000px; /* Change this to your images width */ height:200px; /* Change this to your images height */ overflow: hidden; } nav#access { margin: 0; }
特定のカテゴリーを非表示(Slider)
投稿記事を非表示
- 「header.php」ループの前に以下を記述する
- カテゴリSliderのID(2)を記述する(未分類の次に作成したため「2」)
<?php /* Start the Loop */ ?> <?php query_posts($query_string . '&cat=-2'); ?> <?php while ( have_posts() ) : the_post(); ?> …略…
「最近の投稿」で非表示にする
WP PHP widget
- Code内に、カテゴリSliderのID(2)を記述する
<ul> <?php $recentPosts = new WP_Query(); $recentPosts->query('showposts=5&cat=-2'); ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li> <?php endwhile; ?> </ul>
Sliderのカテゴリーが非表示になります。
「Simple Nivo Slider」の場合も、記事投稿を利用するため「非表示」の設定が必要になります。