WP_Query use for a filter with multiple Taxonomies and Terms

Try this way: $args = array( ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_status’ => ‘publish’ ); if ( isset( $_POST[‘typefilter’] ) && $_POST[‘typefilter’] !== ” ) { $args[‘post_type’] = ‘post_type_x’; $args[‘tax_query’][0][‘taxonomy’] = ‘type_emp’; $args[‘tax_query’][0][‘field’] = ‘id’; $args[‘tax_query’][0][‘terms’] = $_POST[‘typefilter’]; $args[‘tax_query’][0][‘operator’] = ‘IN’; } if ( $_POST[‘typefilter’] == ”) { $args[‘post_type’] = ‘post_type_x’; } // If … Read more

Remove commas from WooCommerce checkout addresses fields

You can remove/replace comas from address_1 and address_2 billing and shipping fields with the following, once order is submitted (before saving data): // Checkout/Order: Remove/replace comas from adresses fields add_action(‘woocommerce_checkout_create_order’, ‘remove_comas_from_address_fields’, 10, 2 ); function remove_comas_from_address_fields( $order, $data ) { $replacement=””; if ( $billing_address_1 = $order->get_billing_address_1() ) { $order->set_billing_address_1( str_replace( ‘,’, $replacement, $billing_address_1 ) ); … Read more

Replace existing content from specific WooCommerce admin orders list column

The correct filter hook to be used is manage_edit-shop_order_columns. 1) To remove shipping_address column: add_filter( ‘manage_edit-shop_order_columns’, ‘remove_specific_orders_column’ ); function remove_specific_orders_column( $columns ){ unset( $columns[‘shipping_address’] ); return $new_columns; } Code goes in functions.php file of the active child theme (or active theme). Tested and works. 2) Replace the content of shipping_address column: Here is an example … Read more

WordPress-site can be reached on x.x.x.x/index.php – but not directly on the IP without index.php

Is this normal behaviour? Yes. On a default Apache install, only index.html is set as the DirectoryIndex (the default setting). Either in the appropriate <VirtualHost> container, or main server config you need to add a <Directory> section that specifically targets the defined document root directory. For example: DocumentRoot /var/www/html <Directory “/var/www/html”> # Allow public access … Read more

Notice: wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder

You don’t need to remove the prepare(), but you just need to do it properly. And please check the $wpdb->prepare() reference for the function’s syntax etc., but basically, instead of (wrapped for brevity): $insert_query = “INSERT INTO `”.$computer_repair_items.”` VALUES(NULL, ‘”.$wc_service_name.”‘, ‘services’, ‘”.$post_id.”‘)”; $wpdb->query( $wpdb->prepare($insert_query) ); you should do it like this: (presuming $computer_repair_items is a … Read more

get understrap pagination to work with custom query

the pagination function does nothing with a custom loop That’s because for custom loops or secondary WP_Query instances like your $catquery variable, you need to explicitly tell the function how many pages are available for your custom query. So the $total argument (see the function’s description) should be set to the max_num_pages property of the … Read more

Why when I instantiate wp_error in a validation method my user registration method stops working?

It seems you need to use $errors = new \WP_Error(); in your code, since WP_Error isn’t part of your namespace. I ran a quick test on my machine, using wp-cli commands: Using new WP_Error(): % wp eval ‘namespace PJ\NS\Test; $x = new WP_Error(); var_dump( $x );’ Fatal error: Uncaught Error: Class ‘PJ\NS\Test\WP_Error’ not found in … Read more

Is $hook a global variable in WordPress

Ok – so, firstly you should know that it is a variable and not a function – in php this is indicated by the dollar symbol before the name: $variable as opposed to function() Second, you should note that $hook is passed as a parameter to the function block – like so: function_name( $hook ){ … Read more

Question about the template-loader.php file

The conditional first checks against what gets returned from the template_include hook. In most cases, a template will be found, and there will be no issue. We’ll only move onto the 2nd conditional if template_include cannot find or cannot load the template. We then look at the WP_Theme object, which does some base-line checks to … Read more