How do I change the initial quantity of a product in woocommerce?

You can use the woocommerce_quantity_input_args filter: function wpse_292293_quantity_input_default( $args, $product ) { $args[‘input_value’] = 2; return $args; } add_filter( ‘woocommerce_quantity_input_args’, ‘wpse_292293_quantity_input_default’, 10, 2 ); When the quantity input is output, it’s output with the woocommerce_quantity_input() function. This function accepts several arguments including the default value for the input. This filter lets you replace values in … Read more

Add notification bubble notice in navigation using transients

Thanks again for the help @jdm2112. Updated a few syntax errors and used the same structure you suggested, works great! // Add notification bubble to custom post type menu nav add_action( ‘admin_menu’, ‘add_cpt_menu_bubble’ ); function add_cpt_menu_bubble() { global $menu; $count_posts = tms_count_pending_posts(); if ( $count_posts > 3 ) { foreach ( $menu as $key => … Read more

Get Objects While Deleting term

Use the pre_delete_term hook, which fires before the actual deleting occurs, so the relationships will still be present. function wpse_296972_pre_delete_term( $term_id, $taxonomy_name ) { if ( $taxonomy_name === ‘organization’ ) { $objects = get_objects_in_term( $term_id, $taxonomy ); // Do something with $objects. } } add_action( ‘pre_delete_term’, ‘wpse_296972_pre_delete_term’ );

The Point of Using apply_filters()

The point is to allow developers to customise aspects of your theme or plugin. When calling apply_filters() you provide a name and a value that you want developers to be able to filter. For your example: $array = apply_filters( ‘du/class/method’ array( ‘index’ => ‘value’, ‘index’ => ‘value’, ‘index’ => ‘value’, ‘index’ => ‘value’, ) ); … Read more

How can i display post loop in table format?

You need 3 separate loops. One for each row, with each post creating a new column: <div class=”acadp”> <table> <tr> <?php while( $acadp_query->have_posts() ) : $acadp_query->the_post(); ?> <td><?php the_title(); ?></td> <?php endwhile; ?> </tr> <tr> <?php while( $acadp_query->have_posts() ) : $acadp_query->the_post(); ?> <td><?php the_content(); ?></td> <?php endwhile; ?> </tr> <tr> <?php while( $acadp_query->have_posts() ) : … Read more

wp_transition_post_status does not change the status of the post

This function contains do_action() calls for post status transition action hooks. The order of the words in the function name might be confusing – it does not change the status of posts, it only calls actions that can be hooked into by plugin developers. https://codex.wordpress.org/Function_Reference/wp_transition_post_status What you want is wp_update_post, you’re also using WP_Query incorrectly: … Read more

How to get color name in PanelColorSettings in custom Gutenberg block?

I could solve it with the function getColorObjectByColorValue (take a look at the gutenberg files). If you have something like const backgroundColors = [ { name: ‘Light Green’, slug: ‘light-green’, color: ‘#E6F0F0’ }, { name: ‘Light Gray’, slug: ‘light-gray’, color: ‘#F7F7F7’ } ]; then you can get the color name by const test = getColorObjectByColorValue(backgroundColors, … Read more