Advertisement
nshelper

Untitled

Aug 21st, 2024 (edited)
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1.     add_action( 'wp_loaded', '_custom_wp_loaded', 99 ) ;
  2.     function _custom_wp_loaded()
  3.         {
  4.             global $wpdb;
  5.  
  6.             // Get the current URL path (strip the domain and query string)
  7.             $request_uri = $_SERVER['REQUEST_URI'];
  8.             $slug = trim($request_uri, '/'); // Remove leading and trailing slashes
  9.  
  10.             // Check if the slug exists in the database
  11.             $page_id = $wpdb->get_var( $wpdb->prepare( "
  12.                SELECT ID
  13.                FROM $wpdb->posts
  14.                WHERE post_name = %s
  15.                AND post_type = 'page'
  16.                AND post_status = 'publish'
  17.            ", $slug ) );
  18.  
  19.             // If a match is found, $page_id will be the ID of the page, otherwise, it will be null.
  20.             if ( $page_id )
  21.                 {
  22.                     // The current page slug matches
  23.                    
  24.                     global $WooGC;
  25.                     $WooGC->functions->remove_anonymous_object_filter( 'switch_blog', 'WooGC_general_filters', 'switch_blog' );          
  26.                    
  27.                 }
  28.                        
  29.            
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement