您可以始终使用适当的WordPress Ajax API(当然不是真正的API),例如:
<li><a href="url to wp-admin/admin-ajax.php?action=my_ajax_tabs&tab=tab1">Tab 1</a></li>
<li><a href="url to wp-admin/admin-ajax.php?action=my_ajax_tabs&tab=tab2">Tab 2</a></li>
然后创建一个响应ajax调用的函数:
function do_my_tabs(){
$tab = $_GET[\'tab\'];
switch ($tab){
case "tab1":
echo \'tab1 content\';
break;
case "tab2":
echo \'tab2 content\';
break;
}
die();
}
最后,挂接此函数:
//if you want only logged in users to access this function use this hook
add_action(\'wp_ajax_my_ajax_tabs\', \'do_my_tabs\');
//if you want none logged in users to access this function use this hook
add_action(\'wp_ajax_nopriv_my_ajax_tabs\', \'do_my_tabs\');
//if you want both logged in users and guests to access this function then add both