WP All Import / Update stock quantity from multiple XML files

I managed to get it working, here is answer: – when importing update new stock to custom field: _custom_stock_placeholder – update only this field: _custom_stock_placeholder – add this code to functions.php add_action(‘pmxi_saved_post’, ‘post_saved’, 10, 1); function post_saved($id) { $original_stock = get_post_meta($id, ‘_stock’, true); $new_stock = get_post_meta($id, ‘_custom_stock_placeholder’, true); $combined_stock= $original_stock + $new_stock; update_post_meta($id, ‘_stock’, $combined_stock); … Read more

Get all the URLs of the pages that uses a specific shortcode

Solution that I’ve found: $pages = get_pages(); $pattern = get_shortcode_regex(); foreach($pages as $page) { if ( preg_match_all( “https://wordpress.stackexchange.com/”. $pattern .’/s’, $page->post_content, $matches ) && array_key_exists( 2, $matches ) && in_array( ‘my_shortcode’, $matches[2] ) ) { echo $page->post_title . <br />; } }

Sorting dynamic select/dropdown for Contact Form 7 of Modern Tribe Events posts

For any poor soul out there that stumbles on the same, niche problem, the answer was frustratingly simple. Instead of trying to reinvent the wheel and build my own query, I should’ve been using the tribe_get_events function that I’m sure the Modern Tribe devs already worked hard to write. Anyway, here’s the final solution for … Read more

Woocommerce Product_cat for current category page

Try to get category info using $category = get_queried_object(); $cpt_cat = $category->term_id; $args = array( ‘post_type’ => ‘product’, ‘posts_per_page’ => 10, ‘tax_query’ => array( array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, ‘terms’ => $cpt_cat, ), ), ); // Custom query. $query = new WP_Query( $args ); if ( $query->have_posts() ) { global $wpdb; /* Start … Read more

get_page_template_slug returns incorrect path

I just checked what the function you called does and it just retrieves the _wp_page_template value from the wp_postmeta table of WordPress. So probably the structure of your theme is not right, some rewrites are active, or something else (e.g. plug-in) altered this database table. You could check that the theme root directory is indeed … Read more

if ( ! function_exists

The child theme functions.php is actually loaded first (this is intentional and desired behaviour.) So despite the function_exists check in your child theme, it will achieve nothing, as it seems the parent theme does not have this wrapper and is loaded second, so a fatal error occurs. There is no easy way to override a … Read more