Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes)

WordPress overrides PHP’s memory limit to 256M, with the assumption that whatever it was set to before is going to be too low to render the dashboard. You can override this by defining WP_MAX_MEMORY_LIMIT in wp-config.php: define( ‘WP_MAX_MEMORY_LIMIT’ , ‘512M’ ); I agree with DanFromGermany, 256M is really a lot of memory for rendering a … Read more

WooCommerce: Finding the products in database

Update 2020 Products are located mainly in the following tables: wp_posts table with post_type like product (or product_variation), wp_postmeta table with post_id as relational index (the product ID). wp_wc_product_meta_lookup table with product_id as relational index (the post ID) | Allow fast queries on specific product data (since WooCommerce 3.7) wp_wc_order_product_lookuptable with product_id as relational index … Read more

Relative URLs in WordPress

I think this is the kind of question only a core developer could/should answer. I’ve researched and found the core ticket #17048: URLs delivered to the browser should be root-relative. Where we can find the reasons explained by Andrew Nacin, lead core developer. He also links to this [wp-hackers] thread. On both those links, these … Read more

How to get the WordPress post thumbnail (featured image) URL?

Check the code below and let me know if it works for you. <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), ‘single-post-thumbnail’ ); ?> <div id=”custom-bg” style=”background-image: url(“https://stackoverflow.com/questions/11261883/<?php echo $image[0]; ?>”)”> </div> <?php endif; ?>

Get orders total purchases amount for the day in Woocommerce

The best and effective way to get that is to use the following very light SQL query, that will get the sum of all order totals in the last 24 hours for “processing” and “completed” orders statuses: function get_daily_purchases_total(){ global $wpdb; return $wpdb->get_var( ” SELECT SUM(pm.meta_value) FROM {$wpdb->prefix}posts as p INNER JOIN {$wpdb->prefix}postmeta as pm … Read more

Add a line break in Woocommerce Product Titles

2020 revision – Still works on WordPress 5.5.1 with WooCommerce 4.4.1 Using this custom function hooked in the_title filter hook will do the job (replacing a pipe character | by a <br> in product titles): add_filter( ‘the_title’, ‘custom_product_title’, 10, 2 ); function custom_product_title( $title, $post_id ){ $post_type = get_post_field( ‘post_type’, $post_id, true ); if( in_array( … Read more

Applied coupons disable Free shipping conditionally in Woocommerce

The below code will enable “Free shipping” for applied coupons only if cart subtotal reaches a minimal amount (discounted including taxes): add_filter( ‘woocommerce_package_rates’, ‘coupons_removes_free_shipping’, 10, 2 ); function coupons_removes_free_shipping( $rates, $package ){ if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return $rates; $min_subtotal = 250; // Minimal subtotal allowing free shipping // Get needed … Read more