epl_archive_page_id: choose the Elementor page used as the listings archive
Description #
Under Easy Property Listings > Settings > Elementor Templates you can show a page built in Elementor in place of EPL's archive, search results and taxonomy templates. This filter changes which page is used for the current request. Return 0 to use EPL's normal template.
It only runs on the front end (not in the Elementor editor) when Use An Elementor Page As The Archive is enabled and the request is an EPL listing archive, an EPL search (when Apply To Search Results is on), or a location, tax_feature or tax_business_listing page (when Apply To Location/Feature Archives is on). It runs on template_include.
The starting value is the page set for the listing type (setting epl_archive_page_id_<type>), otherwise the site-wide Listings Archive Page (epl_archive_page_id); both are read with epl_get_option(). The page you return is only used when it's a published page that isn't password protected. An Elementor Pro Theme Builder Archive template that applies to the request still wins.
EPL shows the page inside the theme's header and footer and leaves the main query alone, so pagination and the page URL stay correct. The page needs a Listings Results widget to show the listings.
Part of the Elementor integration, which is in beta. See Elementor widgets and templates (beta) for how the widgets and templates fit together.
Usage #
add_filter( 'epl_archive_page_id', 'my_function', 10, 2 );
Parameters #
$page_id (int)
The page to show. Default the per-type page, then the Listings Archive Page, or 0.
$queried_type (string)
The listing type the request shows, for example rental. Empty when the request covers more than one type (for example a search across types or a location page).
Examples #
Use page 789 for location pages:
function my_epl_location_archive_page( $page_id, $queried_type ) {
if ( is_tax( 'location' ) ) {
return 789;
}
return $page_id;
}
add_filter( 'epl_archive_page_id', 'my_epl_location_archive_page', 10, 2 );
Source #
lib/page-builders/elementor/class-epl-elementor-template-router.php, in EPL_Elementor_Template_Router::resolve_archive_page_id(), called from maybe_route_archive() on template_include. The page is printed by lib/templates/themes/elementor/archive-page.php. Since 3.6.