What is the correct method for determining ‘is_front_page’ when using filters such as ‘pre_get_posts’ and ‘posts_where’?

Regarding the posts_orderby, posts_where, posts_join and posts_clauses hooks, the current \WP_Query object is available through the second input argument. These are the relevant parts from the \WP_Query class: $orderby = apply_filters_ref_array( ‘posts_orderby’, array( $orderby, &$this ) ); $where = apply_filters_ref_array( ‘posts_where’, array( $where, &$this ) ); $join = apply_filters_ref_array( ‘posts_join’, array( $join, &$this ) ); … Read more

What is the condition to check if we are in admin or frontend?

Take a look at the is_admin() conditional tag: function wpse106895_dummy_func() { if ( ! is_admin() ) { // do your thing } } add_action( ‘some-hook’, ‘wpse106895_dummy_func’ ); is_admin() returns true, if the URL being accessed is in the dashboard / wp-admin. Hence it’s negation (via the not operator) is true when in the frontend. Update, … Read more