Vehicle_URLs_By_VIN::find_vehicle_url( string $vin )

Takes a VIN and finds its permalink. If the vehicle is not in inventory, the vehicle archive URL is returned.


Parameters Parameters

$vin

(string) (Required) A vehicle identification number.


Top ↑

Return Return

(string) A vehicle permalink or the link to the vehicle archive.


Top ↑

Source Source

File: includes/class-vehicle-urls-by-vin.php

		protected function find_vehicle_url( $vin ) {
			$posts = get_posts(
				array(
					'post_type'   => INVP::POST_TYPE,
					'post_status' => 'publish',
					'meta_key'    => apply_filters( 'invp_prefix_meta_key', 'vin' ),
					'meta_value'  => $vin,
				)
			);
			if ( 1 === count( $posts ) ) {
				return get_permalink( $posts[0] );
			}
			return get_post_type_archive_link( INVP::POST_TYPE );
		}