0
我創建了一個插件,通過使用此代碼創作的WordPress插件創建子菜單的
add_filter('page_template', 'in_page_template');
function in_page_template()
{
global $wpdb;
$new_page_title = 'Packages';
$sql = "SELECT * FROM wp_posts where post_name='" . $new_page_title . "';";
$cnt_post = $wpdb->get_results($sql);
if (!(is_page('Home'))) {
$ppid = $_GET['page_id'];
if (count($cnt_post) != 0) {
$pid = $cnt_post[0]->ID;
if ($pid == $ppid) {
$page_template = dirname(__FILE__) . '/Packages.php';
return $page_template;
}
}
}
}
我怎樣才能爲包頁面創建子菜單創建菜單
你不應該使用的表你的查詢中的名字用'$ wpdb-> posts'替換'wp_posts' http://codex.wordpress.org/wpdb#Tables – janw