ページを開く毎に画像を切り替える方法
1)ランダムな数字を発生させる。 <?php $cut = rand(0,2); ?> 2)発生させてた数字をechoで表示させる <img src="http://orbit1808.xsrv.jp/wp-content/uploads/cut<?php echo $cut;?>.jpg">
<PHP>
<?php $cut = rand(0,2); ?>
<?php $cut2 = rand(3,4); ?>
<?php $pama = rand(1,3); ?>
<?php $color1 = rand(1,3); ?>
<?php $color2 = rand(4,5); ?>
<HTML>
<ul class="none">
<li><img src="http://orbit1808.xsrv.jp/wp-content/uploads/cut<?php echo $cut;?>.jpg"></li>
<li><img src="http://orbit1808.xsrv.jp/wp-content/uploads/cut<?php echo $cut2;?>.jpg"></li>
<li><img src="http://orbit1808.xsrv.jp/wp-content/uploads/pa-ma<?php echo $pama;?>.jpg"></li>
<li><img src="http://orbit1808.xsrv.jp/wp-content/uploads/color<?php echo $color1;?>.jpg"></li>
<li><img src="http://orbit1808.xsrv.jp/wp-content/uploads/color<?php echo $color2;?>.jpg"></li>
</ul>
<CSS>
.cutstyle ul li{
float:left;
padding-right:1px;
padding-bottom:1px;
}
ページを開く毎に画像を切り替える方法
<ul class="slidbox none effect-fade">
<?php
$img = "http://asterisk.so-hot.jp/wp-origi/wp-content/themes/intcpt-wp/img/slide";
$ar_num = range(1,8);
shuffle($ar_num);
for ($i = 0 ; $i < 6 ; $i++){
echo '<li class="fadein">' . '<img src="' .$img . $ar_num[$i] .'.gif'. '" >'.'</li>';
}
; ?>
</ul>
ページを開く毎に画像を切り替える方法(カスタムタクソノミーの場合)
<?php if (is_mobile()) : ?>
<?php $post;
$args = array(
'post_type' => 'voice',
'orderby' => 'rand',
'numberposts' => 2
);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);?>
<div class="voice_content random">
<h2><?php the_title() ?></h2>
<?php the_excerpt(); ?>
<a class="readtext" href="<?php the_permalink(); ?>">→ Read more</a>
</div>
<?php endforeach; ?>
<?php else: ?>
<div class="wid1000 effect-fade flex_box">
<?php $post;
$args = array(
'post_type' => 'voice',
'orderby' => 'rand',
'numberposts' => 4
);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post);?>
<div class="voice_content random fadein">
<h2><?php the_title() ?></h2>
<?php the_excerpt(); ?>
<a class="readtext" href="<?php the_permalink(); ?>">→ Read more</a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
ページを開く毎に画像を切り替える方法(カテゴリ一覧の場合)
//cat=カテゴリID showposts=表示件数
<?php query_posts('cat=10&showposts=4&orderby=rand'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<div class="post"><?php the_content(); ?></div>
<?php endwhile;endif;?>
<?php wp_reset_query(); ?>