How to list wordpress posts by author

November 4, 2008

You first need to know the ID of each author you want to list posts. On your WordPress dashboard, go to Users. When you put your mouse over an username, look for the adress appearing in your browser’s status bar. The user ID is displayed in the url. Once you have the ID(s), paste the following code where you want to list the post from a specific author: $numposts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_author = 1"); echo "Posts by Author 1"; <ul> foreach ($numposts as $numpost) { echo... [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]

Display subpages on your wordpress sidebar

November 1, 2008

If you use pages and subpages on your blog, it can be a good idea to use your sidebar to create a menu of subpages. If you’d like to try, the following code is what you need! In order to achieve this recipe, place the following code on your sidebar.php file. <?php $children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0'); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?> The above code executes the wp_list_pages function, with the echo=0... [Read the full story]

Page 10 of 10« First...«678910