我想包括非本地WordPress表中列出的类别,以在“正常”wp页面导航中显示(该表来自WP-Filebase 并被称为->prefix .wpfb_cats
)
我已经在我的主题功能文件中添加了以下内容,它确实将类别添加到导航中,并按照正确的层次顺序进行排列。然而,这些都没有任何链接(我想这是因为这些页面在wp_post
表格)
我如何说服wp将其识别为页面,并在单击时显示内容<我用的是右钩子吗
当我在该函数末尾回显WPPost对象时,这些额外的页面在那里,但只有标题。如何在导航中显示链接?
add_filter(\'get_pages\',\'msci_wpfb_frontend_menus\',10,2);
function msci_wpfb_frontend_menus($pages,$query){
global $wpdb;
$wpfbCats=$wpdb->get_results("SELECT * FROM ".$wpdb->wpfilebase_cats." WHERE cat_exclude_browser=\'0\' ", ARRAY_A );
foreach($wpfbCats as $k=>$v){
$wpfbId=9999;/*add improbably high id so there are no clashes with any actually existing pages**/
$id=$wpfbId+$v[\'cat_id\'];
if($v[\'cat_parent\']==0){
$pid=4;/*display the wpfb top categories under this - existing - page*/
}else{
$pid=$wpfbId+$v[\'cat_parent\'];
}
$name=$v[\'cat_name\'];
$page=array(
\'ID\' => $id,
\'post_author\' => $v[\'cat_owner\'],
\'post_date\' => date(\'Y-m-d H:i:s\'),
\'post_date_gmt\' => date(\'Y-m-d H:i:s\'),
\'post_content\' => \'####some content####\',
\'post_title\' => $v[\'cat_name\'],
\'post_excerpt\' => \'\',
\'post_status\' => \'publish\',
\'comment_status\' => \'closed\',
\'ping_status\' => \'closed\',
\'post_password\' => \'\',
\'post_name\' => sanitize_title($v[\'cat_name\']),
\'to_ping\' => \'\',
\'pinged\' => \'\',
\'post_modified\' => date(\'Y-m-d H:i:s\'),
\'post_modified_gmt\' => date(\'Y-m-d H:i:s\'),
\'post_content_filtered\' => \'\',
\'post_parent\' => $pid,
\'guid\' => \'\'.$id.\'\',
\'menu_order\' => $v[\'cat_order\'],
\'post_type\' => \'page\',
\'post_mime_type\' => \'\',
\'comment_count\' => 0,
\'filter\' => \'raw\'
);
$wpfbCat = new WP_Post ();
foreach($page as $k=>$v){
$wpfbCat->$k=$v;
}
$pages[]=$wpfbCat;
}
return $pages;
}