Author Avatar as default first image

There was a lotta junk in that function, here’s all you need: function get_post_image() { global $post; if ( preg_match( ‘/<img.+?src=[\'”]([^\'”]+)[\'”].*>/i’, $post->post_content, $matches ) ) $image = $matches[1]; else $image = get_avatar( $post->post_author ); return $image; }

Show recent posts in a table format

You still can use lists – just use proper CSS (every third li – first li in every row – should have clear property set; You can use CSS classes or :nth-child selector to do this). If you really have to use table (I don’t suggest it – it’s not a very good idea, because … Read more

adding new posts into wordpress DB automatically

You can use the wp_insert_post function $my_post = array( ‘post_title’ => ‘Some titles’, ‘post_content’ => ‘This is my post content’, ‘post_status’ => ‘publish’, ‘post_author’ => 1, ‘post_category’ => array(1, 2, 9000) ); // Insert the post into the database wp_insert_post( $my_post ); }

Problem with trying to display subheader in posts

You easily add an H4 tag in the “Visual” version of the editor (the tab on the upper right corner of the editor) by selecting the text you want to be the subheader at the top of the rich text editor there is a buttom at the end of the first row of icons called … Read more

How can I create an RSS feed that includes “Private” posts?

I assume your theme already has a ‘feed-rss.php’ (if not, here’s how they work: http://codex.wordpress.org/Customizing_Feeds) You’ll need to pass a few parameters to the query before you loop through them. //Get all posts that are private or public $the_query = new WP_Query( array( ‘post_status’ => array( ‘private’, ‘publish’ ) ); while ( $the_query->have_posts() ) { … Read more

Post Templates and Post ID’s

But for some reason my posts get overridden instead of displaying new data. The problem is here: $announcements->query(‘showposts=1&cat=$category_id’); You are trying to use a variable inside a single quote string. Variables do not expand inside single quotes so instead of asking for cat=1, or cat=2, you are literally asking for cat=$category_id— just like that, spelled … Read more

Same post appears in related Posts?

Aahhh, it’s a typo, I guess. There is no parameter called posts__not_in. It’s called post__not_in. So you should change your code to: function dark_delight_get_related_posts(){ $post = get_post(); $args = array( ‘posts_per_page’ => 4, ‘ignore_sticky_posts’ => true, ‘post__not_in’ => array($post->ID), // post and not posts ); $categories = get_the_category(); if( !empty($categories) ){ $category = array_shift( $categories … Read more

Inserting Media to WordPress Posts

If you use “Insert by URL” the image is loaded from whatever URL your provide. It is not uploaded to your server at all, nor is any information added to the postmeta table as far as I can tell. It seems to be equivalent to simple hand-writing the HTML into the post body. You can … Read more