Mobile Theme Post Order
-
Hi Theme
I’m trying to change the way posts are ordered when on the mobile theme and I don’t think I’m getting the hook quite right. I wish to change the “orderby” value to “_expiration_date” as I have it on my desktop homepage.
Here’s what I tried:
// Check if we are on mobile function jetpackme_is_mobile() { // Are Jetpack Mobile functions available? if ( ! function_exists( 'jetpack_is_mobile' ) ) return false; // Is Mobile theme showing? if ( isset( $_COOKIE['akm_mobile'] ) && $_COOKIE['akm_mobile'] == 'false' ) return false; return jetpack_is_mobile(); } // Modify the main query on the home page for the mobile theme. function jetpackme_modify_main_query( $query ) { if ( jetpackme_is_mobile() && is_home() ) { $query->set('orderby', 'meta_value'); $query->set( 'meta_key', '_expiration-date' ); $query->set( 'order', 'ASC' ); return; } } add_action( 'pre_get_posts', 'jetpackme_modify_main_query' );
Any help would be welcome.
Cheers harry
- The topic ‘Mobile Theme Post Order’ is closed to new replies.