• Resolved nielss

    (@nielss)


    The complete error without strack trace:

    Fatal error: Uncaught Error: Call to a member function get_page_permastruct() on null in C:\xampp\htdocs\TwizoAdminTFA\wp-includes\link-template.php:357

    The code that causes it:

    if(!$this->page_exists_by_slug('twizo-verification')){
                $newPage = array(
                    'post_title' => '2FA Settings',
                    'post_name' => 'twizo-verification',
                    'post_type' => 'page',
                    'post_status' => 'publish'
                );
    
                wp_insert_post($newPage);
            }
    
    public function page_exists_by_slug($page_slug) {
            
            $page = get_page_by_path( $page_slug , OBJECT );
        
            if ( isset($page) )
               return true;
            else
               return false;
        }

    I found out that $wp_rewrite is null in link-template.php, but I don’t know why.

Viewing 1 replies (of 1 total)
  • Thread Starter nielss

    (@nielss)

    Nvm, I fixed it. I was adding the page before wp_loaded was called.

Viewing 1 replies (of 1 total)
  • The topic ‘Call to a member function get_page_permastruct() on null in link-template.php’ is closed to new replies.