wp_query not working with post_type

First I would state that in most cases the query_posts should be avoided! This function will completely override the main query and isn’t intended for use by plugins or themes. Its overly-simplistic approach to modifying the main query can be problematic and should be avoided wherever possible. I would suggest transfer your query with WP_Query … Read more

Sort posts in loop by the WooCommerce Membership of the author

I would flag post as member_post when it is submitted to database and use this flag to sort them. function wpse_287048_flag_member_post( $post_id ) { if ( wc_memberships_get_user_active_memberships() !== false ) { // Check if user is member update_post_meta( $post_id, ‘member_post’, 1 ); } else { update_post_meta( $post_id, ‘member_post’, 0 ); } } add_action( ‘save_post’, ‘wpse_287048_flag_member_post’ … Read more

Replacing a deprecated filter ‘woocommerce_get_price’ with ‘woocommerce_product_get_price’

It’s hard to find because the hook name is generated dynamically. All the get_ functions in the WooCommerce product class, like $product->get_price(), use the get_prop() method under the hood. This is part of the WC_Data class that WC_Product extends. At the end of get_prop() the filters are applied like this: apply_filters( $this->get_hook_prefix() . $key, $value, … Read more

I want to run a script only once on a ‘thank you’ page

You can use order post meta to check order already there or not. try below code. let me know if this helps you. $order_id = $order->get_id(); $fbpixel = get_post_meta($order_id, ‘fbpixel-‘.$order->get_order_number(),true); if ( $order->get_subtotal() > 0 && ( empty( $fbpixel ) ) ) : update_post_meta($order_id, ‘fbpixel-‘.$order->get_order_number(),1); ?> <script> fbq(‘track’, ‘Purchase’, {currency: “AUD”, value: <?php echo ($order->get_total() … Read more