Search Results

Search again:

STOP STOP STOP: DO NOT ACTIVATE THIS CODE BLOCK. COPY THE CODE BELOW AND PASTE IN YOUR FUNCTIONS.PHP FILE. ONCE YOU'VE ADDED IT TO FUNCTIONS.PHP, DELETE THIS CODE BLOCK.

/**
Identify search results by content type
**/

add_filter( 'bricks/code/echo_function_names', function() {
  return [
    'frames_get_current_post_type',
  ];
} );

if ( ! function_exists( 'frames_get_custom_post_type' ) ) {
 
	function frames_get_current_post_type() {
		global $post;

		if (is_search()) {
			return $post ? get_post_type($post) : 'search';
		} elseif (is_singular()) {
			return get_post_type();
		} elseif (is_post_type_archive()) {
			$queried_object = get_queried_object();
			return $queried_object ? $queried_object->name : 'archive';
		} elseif (is_tax()) {
			$tax = get_taxonomy(get_queried_object()->taxonomy);
			return $tax && !empty($tax->object_type) ? $tax->object_type[0] : 'taxonomy';
		} else {
			return 'post'; // Default to 'post' if we can't determine the post type
		}
	}
}