Fix for DIVI Page Builder when the GeoDirectory Search page has no results

Problem: The DIVI Page Builder does not check whether a template is active for the GeoDirectory Search page

When there are no results to be displayed on the GeoDirectory Search page, DIVI does not check if the Search page is built with the DIVI Page Builder. The Search page will look different with results than without results

To fix this, add the following code to the functions.php file of your Divi child theme.
(Note that using the Code Snippets plugin for this fix may not work)

/**
 * Fix GeoDirectory + Divi theme search empty results page.
 */
if ( ! function_exists( 'et_pb_is_pagebuilder_used' ) ) {
	function et_pb_is_pagebuilder_used( $page_id = 0 ) {
		if ( 0 === $page_id ) {
			$page_id = et_core_page_resource_get_the_ID();
		}

		global $wp_query;

		if ( empty( $page_id ) && ! empty( $wp_query ) && $wp_query->is_main_query() && function_exists( 'geodir_is_geodir_page' ) && geodir_is_geodir_page() ) {
			if ( geodir_is_page( 'search' ) ) {
				$page_id = geodir_search_page_id();
			} elseif ( geodir_is_page( 'archive' ) || geodir_is_page( 'post_type' ) ) {
				$page_id = geodir_archive_page_id( ( ! empty( $wp_query->query_vars['post_type'] ) ? $wp_query->query_vars['post_type'] : '' ) );
			}
		}

		return (
			'on' === get_post_meta( $page_id, '_et_pb_use_builder', true ) ||
			// Divi layout post type always use the builder
			'et_pb_layout' === get_post_type( $page_id ) ||
			// Extra Category post type always use the builder
			'layout' === get_post_type( $page_id )
		);
	}
}
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.