I’m listing up articles (pages) by inserting this shortcode:
[wpv-view name="menu-articles" ids="4799, 4793, 4801, 11824, 7344, 4455, 792, 830, 4643, 4658”]
How do I list the articles in the same order as the ids in the shortcode?
Thanks in advance 🙂

Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
To order the view result based on the shortcode attribute "ids" values, you will have to add the view's filter hook "wpv_filter_query":
You should try to add the following code to "Custom Code" section offered by Toolset:
=> https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/#adding-custom-php-code-using-toolset
add_filter( 'wpv_filter_query', 'func_orderby_shortcode_attribute_values', 101, 3 );
function func_orderby_shortcode_attribute_values($query, $setting, $views_ID) {
if($views_ID == 99999) {
$query['orderby'] = 'post__in';
}
return $query;
}
Where:
Replace 99999 with your original view ID.
More Info:
- https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
Problem solved – thanks 🙂