Hello!
Thank you for the reply and help.
I use ACF and I create the layouts via admin pages and insert shortcodes.
I tried it but as you said it applied to all my layouts and the one that do not have the custom field “list_number” did not show any content at all.
—–
Will try to explain how I use it, it’s on localhost right now so can’t show you.
I have three custom post types called Products, Gifts, and Toplists. These are for products (a little bit like thisiswhyimbroke.com) and I use your plugin to display the products with different custom fields. (I will buy your search and filter plugin too soon to use on some places on the website)
But I also use your plugin to display regual post grids.
The “Products”, “Gifts” and “Toplists” custom post type grids I would like to orderby the custom field “list_number”, #1,#2,#3 etc.
But the regual grids with posts I want to order by Published Date. If this is possible.
I tried
function layout_query_args( $query_args ) {
// Modify the query args
$query_args['post_type'] = array( 'products', 'gifts', 'toplists' );
$query_args[ 'meta_key' ] = 'list_number';
$query_args[ 'orderby' ] = 'meta_value_num';
$query_args[ 'order' ] = 'DESC';
// Always return in WP filters
return $query_args;
}
add_filter( 'custom-layouts/layout/query_args', 'layout_query_args', 10 );
and
function layout_query_args( $query_args ) {
// Modify the query args
global $post;
if ( $post->post_type == 'products', 'gifts', 'toplists' ) {
$query_args[ 'meta_key' ] = 'list_number';
$query_args[ 'orderby' ] = 'meta_value_num';
$query_args[ 'order' ] = 'DESC';
}
// Always return in WP filters
return $query_args;
}
add_filter( 'custom-layouts/layout/query_args', 'layout_query_args', 10 );
But that did not work.
Hope you understood my long text, and thank you again for the help!