Adding Author Filter to CPTs

This isn’t a WordPress problem, it’s a programming logic mistake in this if statement: if( ‘booking’ || ‘ticket’ !== $post_type ) { This code is the same as this: if( ( ‘booking’ != false ) || ( ‘ticket’ !== $post_type ) ) { Which in plain language is: If “booking” is a truthy value, or … Read more

Display two previous posts on single.php

I hope there are multiple ways to accomplish this, but I suggest you use the following simpler function for this purpose. This is an attempt to grab a post for the current post which excludes it and the previous post: // A custom function in your functions.php file function get_related_previous_post($previous = 0) { global $post; … Read more

Update shortcode values using ajax call

The problem here is how PHP works. Once the server is done processing the GET request for a page, everything related to that request (i.e. values stored in global variables) is cleared and are lost. What you need to is to keep track of, one way or the other, the month index in the front … Read more

What is the PHP Code for Woo Customer Type (New/Returning)

A custom function would be required. You can check for any orders placed by customer details, but I’d recommend using either customer id (best option as you can get the logged in user’s id very easily) or customer email address.. function wpse419519_is_returning_customer( $customer ) { $args = array( ‘limit’ => -1, //Returns all the orders … Read more