1

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

2 Answers 2

2

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();
?>
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.