Last active
May 18, 2017 12:36
-
-
Save mmilosheski/94e8e103cb97ed75b2f4eaf3804eea8d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
modifiying the general wp_query and adding the suppress filters to be off all the time | |
*/ | |
add_action( '__before_loop' , 'modify_main_wp_query1' ); | |
add_action( '__after_loop' , 'modify_main_wp_query1' ); | |
function modify_main_wp_query1() { | |
global $wp_query; | |
switch ( current_filter() ) { | |
case '__before_loop': | |
$args = array( | |
'suppress_filters' => false | |
); | |
//execute the | |
query_posts( $args ); | |
//set global $wp_query object back initial values for boolean and front page id | |
$wp_query->is_page = true; | |
$wp_query->is_singular = true; | |
$wp_query->query_vars['p'] = $front_page_id; | |
$wp_query->query_vars['page_id'] = $front_page_id; | |
break; | |
case '__after_loop': | |
//reset the custom query | |
wp_reset_query(); | |
break; | |
} | |
} | |
function modify_main_wp_query( $query ) { | |
$query->query_vars['suppress_filters'] = false; | |
} | |
add_action( 'pre_get_posts', 'modify_main_wp_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment