Retrieve images in wordpress post content
December 23, 2008
How to get or count the images contained within the content of a post? To achieve this, simply paste the following code on one of your theme files. It will search for all images contained in the post content, and display it. <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <?php $szPostContent = $post->post_content; $szSearchPattern = '~<img [^\>]*\ />~’; // Run preg_match_all to grab all the images and save the results in $aPics preg_match_all( $szSearchPattern,... [Read the full story]
Display a random header image
November 2, 2008
A lot of WordPress users seems to be very interested by being able to display a random header image. we will use the php rand() function, which allows us to get a random number between 1 and 99 (in this exemple), to display a random header on each post or page. If the random number is less than or equals to 33, the first header image will be displayed. Less than or equals to 66, the second header image will be shown, and same for the last one, which will be displayed only if our random number and less than or equals to 99. Paste... [Read the full story]
Floating Images within the post in WordPress
July 22, 2008
If you’ve already upgraded to WordPress 2.6, you might have noticed that WordPress handles images a little differently than the WordPress 2.5 branch and below. The main change is that you can now use the alt field to add a caption, which will wrap a sort of caption below the image. The problem I’ve had with this new setup is that it can cause some problems when trying to float your images due to the new class=”alignleft”, class=”alignright” or class=”aligncentered” elements. The image will still move,... [Read the full story]
Framing your images using CSS
May 8, 2008
I’ll show you a simple yet effective CSS trick that you can use to mimic a frame on a picture and all you’ll need is Notepad to do it. First up, we’ll need our picture. it’s time to add a class to the image source so that we can begin. <img src=“Live Experience URL” alt=“Live Experience” class=”live-pic”> With that exhausting bit of prep work out of the way it’s time to move on to the magic. What you’ll need to do now is open up your CSS file so we can add a new class. In this case it’s called... [Read the full story]



















