Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function university_adjust_queries($query)
- {
- if (!is_admin() and is_post_type_archive('event') and $query->is_main_query()) {
- $today = date('Ymd');
- $query->set('posts_per_page', '3'); // manipulating the posts
- $query->set('meta_key', 'event_date');
- $query->set('orderby', 'meta_value_num');
- $query->set('order', 'ASC');
- $query->set('meta_query', [
- [
- 'key' => 'event_date', // the custom field name
- 'compare' => '>=', // the operator for the condition
- 'value' => $today, // the value the we are using to compare the key
- 'type' => 'numeric', // the type of key
- ],
- ]);
- }
- /**
- * query for program posts
- */
- if (!is_admin() && is_post_type_archive('program') && $query->is_main_query()) {
- $today = date('Ymd');
- $query->set('posts_per_page', -1); // manipulating the posts
- $query->set('orderby', 'title');
- $query->set('order', 'ASC');
- }
- // query for program posts
- if (!is_admin() && is_post_type_archive('campus') && $query->is_main_query()) {
- $query->set('posts_per_page', -1); // manipulating the posts
- }
- // query for program posts
- if (!is_admin() && is_post_type_archive('professor') && $query->is_main_query()) {
- $query->set('posts_per_page', -1); // manipulating the posts
- }
- }
- add_action('pre_get_posts', 'university_adjust_queries');
- /**
- * Redirect Subscriber accounts out of admin and o n to homepage
- */
- add_action('admin_init', 'redirectSubsToFrontend');
- function redirectSubsToFrontend(){
- $ourCurrentUser = wp_get_current_user();
- if(count($ourCurrentUser->roles) == 1 AND ($ourCurrentUser->roles[0] == 'subscriber')){
- wp_redirect(site_url('/'));
- exit;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement