Appearance
Are you an LLM? You can read better optimized documentation at /rubenz/wp/tips-tricks/changing-post-type-in-dynamic-widgets.md for this page in Markdown format
Changing Post Type in Dynamic Widgets ​
In case you want to display posts other than arts_portfolio_item in Elementor dynamic widgets, you can use the following filters to modify the query used to fetch the posts.
php
add_filter( 'arts/elementor/rubenz_widget_portfolio_fullscreen_headings_slider/query_args' );
add_filter( 'arts/elementor/rubenz_widget_portfolio_fullscreen_slider/query_args' );
add_filter( 'arts/elementor/rubenz_widget_portfolio_fullscreen_two_rows_slider/query_args' );
add_filter( 'arts/elementor/rubenz_widget_portfolio_masonry_grid/query_args' );The code from the examples below can be used in the functions.php file of Rubenz child theme.
Example 1 ​
Make <ThemeName /> Widget Portfolio Fullscreen Headings Slider always display pages in the slider instead of portfolio items:
php
add_filter( 'arts/elementor/rubenz_widget_portfolio_fullscreen_headings_slider/query_args', 'custom_rubenz_widget_portfolio_fullscreen_headings_slider_query_args' );
function custom_rubenz_widget_portfolio_fullscreen_headings_slider_query_args( $args ) {
$args = array(
'post_type' => 'page', // page, post, arts_portfolio_item, etc
);
return $args;
}Example 2 ​
In case you want to apply the filter on a specific page only, feel free to use any conditional statements that help your filter target the right page or post.
php
add_filter( 'arts/elementor/rubenz_widget_portfolio_fullscreen_headings_slider/query_args', 'custom_rubenz_widget_portfolio_fullscreen_headings_slider_query_args' );
function custom_rubenz_widget_portfolio_fullscreen_headings_slider_query_args( $args ) {
global $post;
if ( $post->ID === 16 ) {
$args = array(
'post_type' => 'page', // page, post, arts_portfolio_item, etc
);
}
return $args;
}