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

If Meta Checkbox is checked, do something?

You’re setting a value whether it’s checked or not with this line: $chk = ( isset( $_POST[‘special_box_check’] ) && $_POST[‘special_box_check’] ) ? ‘on’ : ‘off’; The value is going to be either on or off, so your if condition is always true, since it always has a value. You could change it to save only … Read more

Reposition Woocommerce Message

WooCommerce renders messages by using woocommerce_show_messages() function. This function is hooked to woocommerce_before_single_product action. So if you don’t want to render messages before single product, you need to remove that hook for the action. remove_action( ‘woocommerce_before_single_product’, ‘woocommerce_show_messages’ ); If you want to render messages in another place, then just call woocommerce_show_messages() function in desired place.