INVP::have_new_and_used_vehicles()

Checks if there are both ‘new’ and ‘used’ vehicles in the inventory.

On This Page


Return Return

(bool) True if both new and used vehicles exist, false otherwise.


Top ↑

Source Source

File: includes/class-invp.php

	public static function have_new_and_used_vehicles() {
		$new_query  = new WP_Query(
			array(
				'post_type'      => self::POST_TYPE,
				'post_status'    => 'publish',
				'posts_per_page' => 1,
				'tax_query'      => array(
					array(
						'taxonomy' => 'condition',
						'field'    => 'slug',
						'terms'    => 'new',
					),
				),
			)
		);
		$used_query = new WP_Query(
			array(
				'post_type'      => self::POST_TYPE,
				'post_status'    => 'publish',
				'posts_per_page' => 1,
				'tax_query'      => array(
					array(
						'taxonomy' => 'condition',
						'field'    => 'slug',
						'terms'    => 'used',
					),
				),
			)
		);
		return ( $new_query->have_posts() && $used_query->have_posts() );
	}