To include any file in the function file of WordPress just creates a file with the name
i.e custom.php
custom.php
<?php
====================Your code===============
?>
Go to function.php
Use anyone.
1) include ()
Include function includes the specified file and it will throw PHP warning if the file isn't found.
include(dirname( ABSPATH ) .'/admin-page.php');
this will return /var/www/vhosts/foo.bar/httpdocs/includes/baz.php
2) include_once()
include_once() works as inlude() and it will not include file
again if already included.
include_once( get_stylesheet_directory() .'/admin-page.php');
3) require()
require() works same as include() but PHP fatal error will be trown
if the file is not
exists
require(dirname( ABSPATH ) .'/admin-page.php');
4) require_once()
require_once() performs as require() but fill will be not included
second time.
require_once( get_stylesheet_directory()
.'/admin-page.php');
For Parent Theme: get_template_directory()
or get_template_directory_uri()
For Child Theme: get_stylesheet_directory()
or get_stylesheet_directory_uri()
No comments:
Post a Comment