how can i show only the parents in owl-carousel?

According to the documentation, you would have to use post_parent => 0 So your code would look like this: <div class=”owl-carousel owl-theme”> <?php $c = 0; $q2 = new WP_Query( array( ‘post_type’ => array( ‘post’, ‘book’ ), ‘post_status’ => ‘publish’, ‘post_parent’ => 0, //add this here ‘orderby’ => ‘modified’, ‘order’ => ‘desc’ ) ); while … Read more

How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?

You could do something like this add_action(‘pre_get_posts’, ‘bt_search_posts’); function bt_search_posts ($query) { // the posts ids that contain foo bar OR lorem ipsum dolor OR ping pong $posts_ids = []; // get the current query vars $query_vars = $query->query_vars; // loop each term we want to search and if found, add the post id into … Read more

woocommerce registration form with klaviyo(don’t work with current user)

Hey guys there are just a few changes in the above code. Check this out it works for me. Note: Please change the LIST_ID to your klaviyo’s list id, and get one private key from your klaviyo account and add it at PRIVATE_API_KEY function send_coupon_to_freshly_registered_user($user_id) { $user = get_user_by(‘id’,$user_id); //new line $user_email = stripslashes($user->user_email); //changed … Read more

Trouble With Conditional Logic in PHP

Did you tried dumping the value of $carousel_image For image field to return Array, return_type must be set to array https://www.advancedcustomfields.com/resources/register-fields-via-php/#field-type%20settings /* (string) Specify the type of value returned by get_field(). Defaults to ‘array’. Choices of ‘array’ (Image Array), ‘url’ (Image URL) or ‘id’ (Image ID) */ ‘return_format’ => ‘array’, Also what’s the use of … Read more

If post ID has_term?

The 3rd parameter of has_term() accepts a WP_Post or Post ID. Docs on has_term(). In your example code, it would look like this: <?php $postid = $_GET[‘post_id’]; if( has_term( ‘campaign’, ‘type’, $postid ) ): ?> //Do something <?php endif; ?> Where campaign would be the term, type would be the taxonomy, and $postid is the … Read more

How to test nonce with AJAX – Plugin development

I see some issues: You ajax action can be only used by logged users. If this is correct, I recommend you add a nopriv action that returns a error message. // Inside Constructor add_action( ‘wp_ajax_nopriv_pp_html_process’, array( $this, ‘pp_html_process_not_logged’ ) ); And create this function : public function pp_html_process_not_logged () { // Status can be used … Read more

Variable global scope [closed]

Globals are generally discourgaged. You can use define instead. <?php define(“FILM_LABEL”, “Films”); define(“SHOW_LABEL”, “Shows”); function CreatePostTypes() { register_post_type( FILM_LABEL, GenerateFilmType( FILM_LABEL ) ); register_post_type( SHOW_LABEL, GenerateFilmType( SHOW_LABEL ) ); } add_action( ‘init’, ‘CreatePostTypes’ );