How do you check whether a request is from the admin panel?
-
I’m filtering some posts, and it’s working fine in the from end, but it’s also filtering the posts in the admin, which I don’t want.
Here is some example code of what I’m trying to do, and the ??? is where I’m stuck
add_filter('the_posts', 'my_function' , 1 ); function my_function( $posts ) { // // Check to see if we are logged into the admin panel // if (???) { return $posts; } // // If we are not in the admin, filter the posts // // create an array to hold the posts we want to show $new_posts = array(); // // loop through all the post objects // foreach( $posts as $post ) { $include = true; // // Perform Filter comparison // if ($filterPost>=1) { $include = false; } // // if we want to include it then // add the post object to the new posts array // if ( $include === true ) { $new_posts[] = $post; } } // // send the new post array back to be used by WordPress // return $new_posts; }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘How do you check whether a request is from the admin panel?’ is closed to new replies.