Hide editor while keeping add media button in custom post type

WordPress uses the function wp_editor() and there are no parameter that will disable the textarea (what i can see). So i think that you can just hide it with some css. function wpse_78595_hide_editor() { global $current_screen; if( $current_screen->post_type == ‘custom_post_type_name’ ) { $css=”<style type=”text/css”>”; $css .= ‘#wp-content-editor-container, #post-status-info, .wp-switch-editor { display: none; }’; $css .= … Read more

Errors when uploading images in WP 3.5

This was addressed on the Minimatica website: http://www.onedesigns.com/support/topic/how-to-fix-issues-with-media-uploader-with-minimatica-in-wordpress-3-5 You will need to update your functions.php file as follows: In functions.php find this line (line 225 if you haven’t altered the file): add_action(‘init’, ‘minimatica_register_styles’); and replace it with — add_action(‘wp_enqueue_scripts’, ‘minimatica_register_styles’); AND Then find this line (line 437 if you haven’t altered the file): add_filter( ‘ext2type’, … Read more

How to recognise on which site the content is being rendered?

You can use the global $template. The following function returns the basename of the template file being used: index, archive, etc. function get_template_name_wpse_85011() { global $template; $filename = basename( $template, ‘.php’ ); return $filename; } And use it in your template with something like: $templat = get_template_name_wpse_85011(); switch( $templat ) { case ‘index’: // do … Read more

Show category images on single product page and product overview page

I had the same problem and I came up with this solution, hope it helps. <?php $terms = get_the_terms( $post->ID, ‘product_cat’ ); foreach ( $terms as $term ){ $category_name = $term->name; $category_thumbnail = get_woocommerce_term_meta($term->term_id, ‘thumbnail_id’, true); $image = wp_get_attachment_url($category_thumbnail); echo ‘<img src=”‘.$image.'”>’; } ?>

Set featured image randomly from WordPress Database on post submission

Here is a way: // listen for post being published add_action(‘publish_post’, ‘dreis_random_featured_image’); function dreis_random_featured_image() { global $post; // find one random image $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’ ); $random_image = new WP_Query($args); foreach($random_image as $image){ // set as thumbnail set_post_thumbnail($post->ID, $image->ID); } … Read more

Out of memory error reporting

How do your users upload photos? You’re right about register_shutdown_function. It seems to work well in my code, though I only ever call my back-end via AJAX (I’ve also got file upload functionality), and so only need to account for this case. Here’s how I set it up in my plugin. Outside of the plugin … Read more