Reputation: 41
I have wordpress Child Theme and I add php file to this child theme. Also I want to use wordpress function in this file ( I want to show header, menu and footer )
So I try
<?php
$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
require_once( $parse_uri[0] . 'wp-load.php' );
?>
Also I try to add header and footer
<?php get_header();?>
//my content
<?php get_footer();
But it seems it cant load all css/js files and page have bad styling
Upvotes: 1
Views: 75
Reputation: 674
I agree with @Omnisite , If you want to use wordpress function in separate file the make use of wp-blog-header.php like below
require( ABSPATH . 'wp-blog-header.php' );
And if you want to use template function like get_header() and get_footer() then declare that file as a template file like
<?php
/*
Template Name: XYZ
*/
get_header();
//my content
get_footer();
?>
Upvotes: 2
Reputation: 287
If you want to use WP functions in a seperate PHP file, all you have to do is include wp-blog-header.php. Like:
Make sure you have the correct path before wp-blog-header.php.
Upvotes: 0