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

How to display categories of my Custom Post Type?

Remove your code from portfolio-type.php that registers post type and taxonomy (line 9 onwards). Use the following code (in portfolio-type.php) to register the post type “portfolio” function portfolio_register() { $labels = array( ‘name’ => _x(‘Portfolio’, ‘post type general name’), ‘singular_name’ => _x(‘Portfolio Item’, ‘post type singular name’), ‘add_new’ => _x(‘Add New’, ‘portfolio item’), ‘add_new_item’ => … 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

Mega Menu Walker

If I understand the problem setup correctly, you could try to do the break and widget class counting within the wp_nav_menu_objects filter. Here’s an updated example, it’s rather expanded because of the extra debug part: add_filter( ‘wp_nav_menu_objects’, function( $items, $args ) { // Only apply this for the ‘primary’ menu: if( ‘primary’ !== $args->theme_location ) … Read more