Tagged: blog-categories-for-groups, loop, post loop
I’m using the
pre_get_posts
filter (shown below) to sort my homepage post loop by a custom metavalue.function custom_loop_for_loggedin_users( $query ) { if ( is_user_logged_in() && $query->is_home() && $query->is_main_query() && ! is_admin() ) { $user_cat_ids = get_category_ids_of_bp_groups( bp_loggedin_user_id() ); $tax_query = array( array( 'taxonomy' => 'category', 'field' => 'term_id', 'terms' => $user_cat_ids, ), ); $query->set( 'tax_query', $tax_query ); $query->set( 'meta_key', 'hot_rank_score_cached' ); $query->set( 'orderby', array('hot_rank_score_cached' => 'DESC', 'date' => 'DESC')); } } add_action('pre_get_posts','custom_loop_for_loggedin_users');
But I’m also using the Blog Categories for Groups plugin, and would like to apply a similar custom sort to the group blog posts.
I’ve been digging through your plugin to see how you query those posts, but I can’t figure it out.
Am I able to apply a custom sort to the group blog posts? Can you point me in the right direction?
Was hoping to use something like
pre_get_posts
orWP_Query
if possible.Hello Hob,
Thank you for posting. Please take a look on the following URL:
https://github.com/buddydev/blog-categories-for-groups/blob/master/core/bcg-template.php#L27
you can modify using ‘bcg_get_query’ this filter.
Regards
Ravi
You must be logged in to reply to this topic.