How to display recent posts on home page with custom HTML

<div id=”posts”> <?php // define query arguments $args = array( ‘posts_per_page’ => 8, // your ‘x’ goes here ‘nopaging’ = true // possibly more arguments here ); // set up new query $tyler_query = new WP_Query( $args ); // loop through found posts while ( $tyler_query->have_posts() ) : $tyler_query->the_post(); echo ‘<section class=”post”>’. ‘<h2><a href=”‘. get_permalink(). … Read more

WordPress: Remove link in the_tags

Use following code: <?php $posttags = get_the_tags(); if ($posttags) { foreach($posttags as $tag) { echo $tag->name . ‘ ‘; } } ?> More details: http://wpeden.com/tipsntuts/getting-list-of-tags-for-a-post/

wp_handle_upload – The uploaded file could not be moved to wp-content/uploads/2012/09

The move_uploaded_file function is a PHP function: http://php.net/manual/en/function.move-uploaded-file.php One important thing to note about it from that page: This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP’s HTTP POST upload mechanism). If the file is valid, it will be moved to … Read more

Using a switch statement in WordPress

If you wanted to use your switch statement, you could use: switch ($post->post_name){ case ‘home’: $content=”How much money….”; break; case ‘about’: $content=”We design….”; break; case ‘services’: $content=”At the….”; break; case ‘blog’: $content=”Find out whats….”; break; case ‘portfolio’: $content=”Unique, Beautiful….”; break; case ‘contact’: $content=”Get in touch to….”; break; case ‘privacy-policy’: $content=”How much money….”; break; case ‘terms-and-conditions’: … Read more

Custom image upload

May be you are not returning correctly from function, Try this, function insert_attachment($file_handler, $post_id, $setthumb=false) { // check to make sure its a successful upload // changes start if ($_FILES[$file_handler][‘error’] !== UPLOAD_ERR_OK) { return __return_false(); } // changes end require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); $attach_id … Read more

Output 2 items within the Loop

Easy using WP query (get to know it…) <ul> <?php $recentPosts = new WP_Query(); $recentPosts->query(‘showposts=2’); // SET AMOUNT HERE ?> <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> <li><div class=”slide”><?php the_content(); ?></div></li> <?php endwhile; ?> </ul> Hope this helps. Let me know if you encounter any issuse. EDIT 1: * explenation – just added a small conditional … Read more