Elementor custom wp query for page childrens loop

Elementor custom wp query for page childrens loop

If you need to loop children pages of parent page, you can create custom query and call it into Post widget (or any widget for this purpose).

Put this code in functions.php

// Showing children of current page in Posts Widget
add_action( ‘elementor/query/page_childrens_query’, function( $query ) {
// Get current post tags
$current_page = get_queried_object_id();
// Modify the query
$query->set( ‘post_parent’, $current_page );
} );

To enable query, you need to call it in Query settings of widget. For Query ID put name of filter: page_childrens_query

Twitter
Facebook
LinkedIn
Telegram
WhatsApp
Email