admin管理员组文章数量:1431447
I am getting this error which
Fatal error: Uncaught Error: Call to undefined function wp_nav_menu() in /home/stageidg/public_html/idg/wp-content/themes/idg-child/secondmenu.php:2 Stack trace: #0 {main} thrown in /home/stageidg/public_html/idg/wp-content/themes/idg-child/secondmenu.php on line 2
line 2 in the php file is this:
wp_nav_menu( array('menu' => 'Services', 'theme_location'=>'services' ) );
and its being called by this jquery code:
$.ajax(
{
url: ".php", // path to your PHP file
dataType:"html",
success: function(data)
{
$(data).appendTo(inner_overlay); // load-into-div is the ID of the DIV where you load the <select>
} // success
}); // ajax
any idea? what am i doing wrong?
I am getting this error which
Fatal error: Uncaught Error: Call to undefined function wp_nav_menu() in /home/stageidg/public_html/idg/wp-content/themes/idg-child/secondmenu.php:2 Stack trace: #0 {main} thrown in /home/stageidg/public_html/idg/wp-content/themes/idg-child/secondmenu.php on line 2
line 2 in the php file is this:
wp_nav_menu( array('menu' => 'Services', 'theme_location'=>'services' ) );
and its being called by this jquery code:
$.ajax(
{
url: "http://example/idg/wp-content/themes/idg-child/secondmenu.php", // path to your PHP file
dataType:"html",
success: function(data)
{
$(data).appendTo(inner_overlay); // load-into-div is the ID of the DIV where you load the <select>
} // success
}); // ajax
any idea? what am i doing wrong?
Share Improve this question asked Jun 11, 2019 at 19:57 jgax87jgax87 1032 bronze badges 1 |1 Answer
Reset to default -1Yes, like @fuxia says, include wp-load.php to get the WordPress API (wp_nav_menu included) to use. In your case:
<?php
include '../../../../wp-load.php';
This way you did is not wrong but there are better ways to use AJAX in WordPress:
https://codex.wordpress/AJAX_in_Plugins
Be happy, my friend!
本文标签: phpFatal error Uncaught Error Call to undefined function wpnavmenu()
版权声明:本文标题:php - Fatal error: Uncaught Error: Call to undefined function wp_nav_menu() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745412429a2657531.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
secondmenu.php
is called separately, not in a WordPress context, so it doesn't know anything about the WordPress functions. – fuxia ♦ Commented Jun 11, 2019 at 20:11