theme: functions.php
function one_admin_menu() {
add_menu_page(
'One Dashboard',
'One',
'manage_options',
'one_menu',
'one_menu_url',
'dashicons-admin-site',
1
);
}
add_action( 'admin_menu', 'one_admin_menu' );
function one_menu_url() {
include( get_template_directory() . '/includes/admin/main_one/main.php' );
}
main.php
<?php
function one_admin_website() {
$web = get_template_directory_uri() . '/includes/admin/main_one/website.php';
echo $web;
}
?>
<script>
function import_admin_menu(when, where, what) {
jQuery(document).ready(function() {
jQuery(when).click(function() {
jQuery(where).load(what);
});
});
}
</script>
<ul>
<li id='website'><a href="#about">Website</a></li>
</u>
<script>
import_admin_menu('#website', '#one_main_admin', '<?php one_admin_website() ?>' )
</script>
<div id='one_main_admin'> </div>
website.php
my problem is here, just trying to echo template directory and i having Fatal error: Uncaught Error: Call to undefined function get_template_directory_uri()
<?php echo get_template_directory_uri(); ?>
what i made wrong? i have try to search in google in stackoverlow, but didin't found anything. thank you for your time
theme: functions.php
function one_admin_menu() {
add_menu_page(
'One Dashboard',
'One',
'manage_options',
'one_menu',
'one_menu_url',
'dashicons-admin-site',
1
);
}
add_action( 'admin_menu', 'one_admin_menu' );
function one_menu_url() {
include( get_template_directory() . '/includes/admin/main_one/main.php' );
}
main.php
<?php
function one_admin_website() {
$web = get_template_directory_uri() . '/includes/admin/main_one/website.php';
echo $web;
}
?>
<script>
function import_admin_menu(when, where, what) {
jQuery(document).ready(function() {
jQuery(when).click(function() {
jQuery(where).load(what);
});
});
}
</script>
<ul>
<li id='website'><a href="#about">Website</a></li>
</u>
<script>
import_admin_menu('#website', '#one_main_admin', '<?php one_admin_website() ?>' )
</script>
<div id='one_main_admin'> </div>
website.php
my problem is here, just trying to echo template directory and i having Fatal error: Uncaught Error: Call to undefined function get_template_directory_uri()
<?php echo get_template_directory_uri(); ?>
what i made wrong? i have try to search in google in stackoverlow, but didin't found anything. thank you for your time
Please check your domain. In my case url is like this.
http://xxx.local/wp-content/themes/{your_teme}
change to
http://xxx.local/
It fixed. Sometimes wrong url cause this problem.
get_template_directory_url
no
get_template_directory_uri
website.php
directly? – Tom J Nowell ♦ Commented Jan 5, 2017 at 14:51