I want to include categories which are listed in a non-native WordPress table to display within the "normal" wp page navigation (the table comes from WP-Filebase and is called ->prefix .wpfb_cats)

I have put the following in my themes function file, which does add the categories into the navigation and in the right hierachical order. However, none of these have any links (I suppose it's because those pages do not exist as such in the wp_post table )

How can I persuade wp to to recognize these as pages and, when clicked on it, display the content?
Am I using the right hook?
When I echo the WPPost object at the end of that function, these additional pages are in there, but just the title. How can I show links in the navigation?


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**/

                    $pid=4;/*display the wpfb top categories under this - existing - page*/

                    '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){
    return $pages;

1 Answer 1


Try the filter 'page_link', and manipulate the url if id is over $wpfbId


applied to the calculated page URL by the get_page_link function. Filter function arguments: URL, page ID. Note that there is also an internal filter called _get_page_link that can be used to filter the URLS of pages that are not designated as the blog's home page (same arguments). Note that this only applies to Wordpress pages, not posts, custom post types, or attachments.

  • well, blimey. someone came up with a (possible) answer 4 months later :) thanks for the idea, although I have to say that - in the meantime - i did this in an entirely different way, so cant really comment whether this works or not. thanks anyway
    – olly
    Nov 18, 2013 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.