// Start the Loop<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?><?php// Set the post content to a variable$szPostContent = $post->post_content;// Define the pattern to search$szSearchPattern = '~<img <^\>>*\ />~';// Run preg_match_all to grab all the images and save the results in $aPicspreg_match_all( $szSearchPattern, $szPostContent, $aPics );// Count the results $iNumberOfPics = count($aPics<0>);// Check to see if we have at least 1 imageif ( $iNumberOfPics > 0 ){ // Now here you would do whatever you need to do with the images // For this example I'm just going to echo them for ( $i=0; $i < $iNumberOfPics ; $i++ ) { echo $aPics<0><$i>; };};// ...finish the loop, etc
// This time we replace/remove the images from the content$szDescription = preg_replace( $szSearchPattern, '' , $szPostContent);// Apply filters for correct content display$szDescription = apply_filters('the_content', $szDescription);// Echo the Contentecho $szDescription;
<?php$result_random=rand(1, 99);if($result_random<=33){ ?> <div id="header" style="background:transparent url(images/header1.png) no-repeat top left;"><?php }elseif($result_random<=66){ ?> <div id="header" style="background:transparent url(images/header2.png) no-repeat top left;"><?php }elseif($result_random<=99){ ?> <div id="header" style="background:transparent url(images/header3.png) no-repeat top left;"><?php } ?><!-- Header code goes here --></div>
โปรดรอ
cymiz.com insurance