Inventory_Presser_Plugin::change_archive_title_tags( array $title_parts )

Changes the <title> tag on inventory archives.

On This Page


Parameters Parameters

$title_parts

(array) (Required) An array of strings.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: inventory-presser.php

		 * Changes the <title> tag on inventory archives.
		 *
		 * @param  array $title_parts An array of strings.
		 * @return array
		 */
		public function change_archive_title_tags( $title_parts ) {

			if ( ! is_post_type_archive( INVP::POST_TYPE ) ) {
				return $title_parts;
			}

			$title_parts['title'] = '';

			// Is it a make search?
			$query_var = get_query_var( 'make' );
			if ( ! empty( $query_var ) ) {
				$term = get_term_by( 'slug', $query_var[0], 'make' );
				if ( is_object( $term ) && 'WP_Term' === get_class( $term ) ) {
					$title_parts['title'] .= $term->name . ' ';
				}
			}

			// Is it a type search?
			$query_var = get_query_var( 'type' );
			if ( ! empty( $query_var ) ) {
				$term = get_term_by( 'slug', $query_var[0], 'type' );
				if ( is_object( $term ) && 'WP_Term' === get_class( $term ) ) {
					$title_parts['title'] .= $term->name . ' ';
				}
			} else {
				$title_parts['title'] .= __( 'Vehicles', 'inventory-presser' ) . ' ';
			}