Can't load WP function into external function

I created a bookshop website and got header function, footer function and login menu on my front page.

All functions are declared in functions.php and connected to hooks.

My front page runs correctly.

But I try to call registration menu file from one of my options of login menu (file page-non-member.php) and to use use header from front page as a header on this page.

I try to use this:

require( dirname( __FILE__ ) . '../wp-load.php' );
if ( function_exists( 'get_template_part' ) ) {
    echo "get_template_part found";
get_template_part( 'mybookshop', 'header' );  

or that:

do_action( 'create_header_html', 'Make registration' );

But in both cases, I got the next message

Warning: require(W:\domains\wpfolder\wp-content\themes\mybookshop../wp-
load.php): failed to open stream: No such file or directory in
W:\domains\wpfolder\wp-content\themes\mybookshop\page-not-member.php on line

Fatal error: require(): Failed opening required ‘W:\domains\wpfolder\wp-
in W:\domains\wpfolder\wp-content\themes\mybookshop\page-not-member.php on
line 4″.

Structure of my folders:
-- WordPress root directory
 |-- file wp-load.php
 -- my site(bookshop) root directory
 |-- header.php,header.php, page-home-page.php, page-not-member.php, etc

I use a local server(OpenServer). What is the problem and how can I resolve it?

Solutions Collecting From Web of "Can't load WP function into external function"

First of all, don’t do that. Including WordPress’s engine in some external PHP file is not recommended at all. It has more downsides than upsides.

If you want to access WordPress’s functions, create your PHP file inside the theme’s folder, or create a plugin. You can even create an AJAX request if you really need to access some data directly by a URL.

Now, about your error. It seems like you are trying to include wp-load.php from one of your theme’s files. If it is so, then that’s not necessary. Theme’s files already have access to WordPress’s functions. Just remove the require... and you will be fine.

Let’s say for some unknown reasons they don’t, and you HAVE to include wp-load.php. This file exists in the root folder of your installation, and you have to go back 3 times to include it. So it will look like this:


Once again, please don’t do this. It’s not a good practice.