Want to filter my homepage loop by a custom meta

Posted in: Newsmag
Post count: 10

hello,
i use newsmag theme on global.minutenews.fr and i want to change the order of the homepage loop with this custom filter. i use the template VC + last post + pagination but i tried with all template and it’s not working because it seems it’s not the main query .

here is my filter :

// Alter the homepage Query to order by sharecount and date
function hp_pre_get_posts( $query ) {
global $query_string;
// do not modify queries in the admin
if ( is_home() && $query->is_main_query() ) {
$query->set(‘orderby’, ‘date meta_value_num’);
$query->set(‘meta_key’, ‘socialcount_total’);
$query->set(‘order’, ‘DESC’);
}
if ( is_category() && $query->is_main_query() ) {
$query->set(‘orderby’, ‘date meta_value_num’);
$query->set(‘meta_key’, ‘socialcount_total’);
$query->set(‘order’, ‘DESC’);
}

// return
return $query;

}

add_action(‘pre_get_posts’, ‘hp_pre_get_posts’);

can you help me ?

Post count: 6535

Hi

For each block the theme make a custom query depending by the filter set in Visual Composer. The query it’s made in td_data_source.php here http://screencast.com/t/qwy075xXq and the arguments for it are defined here: http://screencast.com/t/8P8ntnH8Nu To add a new sort order you have to edit td_config.php file and add your sort. You can add it either as a new field or simply as an option in sort list: http://screencast.com/t/jP8gMSDk Next step would be to generate the new sort in td_data_source.php by adding the required arguments to query.

Please consider that this is a complex task which require advanced coding skills, also many customization and tests. If you can’t do this by yourself my advice is to look for someone which can help you with this or hire a freelancer to do it for you as we can’t offer any type of custom work at the moment.

Thanks!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newsmag’ is closed to new topics and replies.