What’s the best way to use the Featured Image for responsive web design?

Step 1: Define two custom image sizes, e.g.: <?php add_image_size( ‘normal-thumbnail’, 400, 300, false ); // Default image size add_image_size( ‘mobile-device-thumbnail’, 200, 150, false ); // Mobile-device image size ?> Step 2: Implement your chosen means to determine client. There are several ways, and which method you use is outside the scope of this question. … Read more

How to stop form resubmission on page refresh

Instead of … } else { echo “<p>Your file has been uploaded.</p>”; } … redirect to another address on success: } else { $new_url = add_query_arg( ‘success’, 1, get_permalink() ); wp_redirect( $new_url, 303 ); exit; } Status code 303 triggers a GET request: This method exists primarily to allow the output of a POST-activated script … Read more

WP-CLI – Selecting PHP version

Got the same problem! Just switch the php version. On my server PHP5.6 was default for apache, while CLI was configured with PHP7.1. After installing WP-CLI, with wp –info I got this result: PHP binary: /usr/bin/php7.1 PHP version: 7.1.5-1+deb.sury.org~xenial+1 php.ini used: /etc/php/7.1/cli/php.ini WP-CLI root dir: phar://wp-cli.phar And when i used the wp core install command … Read more

Reposition WooCommerce breadcrumb outside of wrapper content

Ok I seem to have got it working. I added this in the functions file… //Reposition WooCommerce breadcrumb function woocommerce_remove_breadcrumb(){ remove_action( ‘woocommerce_before_main_content’, ‘woocommerce_breadcrumb’, 20 ); } add_action( ‘woocommerce_before_main_content’, ‘woocommerce_remove_breadcrumb’ ); function woocommerce_custom_breadcrumb(){ woocommerce_breadcrumb(); } add_action( ‘woo_custom_breadcrumb’, ‘woocommerce_custom_breadcrumb’ ); Then added… do_action(‘woo_custom_breadcrumb’); …where I wanted the breadcrumb to show.

How can I save a multiple select array with the settings API for a plug-in options page?

So, it looks like two things are going on here: echo “<select id=’$id’ style=”width:15em;height:10em;” class=”select$field_class” name=”” . $buddha_option_name . “[$id]” multiple>”; As noted by @Radek, you could have made the name of the select box an array by using [] – e.g. name=”my_option_name[]” – this will result in the filed $_POST[‘my_option_name’] being an array of … Read more

Limit the number of inactive widgets

Tested under v3.2.1: $sidebars = wp_get_sidebars_widgets(); if(count($sidebars[‘wp_inactive_widgets’]) > 10){ $new_inactive = array_slice($sidebars[‘wp_inactive_widgets’],-10,10); // remove the dead widget options $dead_inactive = array_slice($sidebars[‘wp_inactive_widgets’],0,count($sidebars[‘wp_inactive_widgets’])-10); foreach($dead_inactive as $dead){ $pos = strpos($dead,’-‘); $widget_name = substr($dead,0,$pos); $widget_number = substr($dead,$pos+1); $option = get_option(‘widget_’.$widget_name); unset($option[$widget_number]); update_option(‘widget_’.$widget_name,$option); } // save our new widget setup $sidebars[‘wp_inactive_widgets’] = $new_inactive; wp_set_sidebars_widgets($sidebars); } The above code limits the … Read more

dbDelta support for FOREIGN KEY

Do I really have to live with that until dbDelta supports FOREIGN KEY? Quite frankly, yes. But that’s the beauty of open source – anyone is welcome to post a patch! However, expanding it to cover other aspects of schema design would almost certainly incur unwanted complexity & heighten the possibility of failure – something … Read more