Roshy10
Forum Replies Created
Viewing 4 replies - 1 through 4 (of 4 total)
-
Forum: Hacks
In reply to: add_options_page slug not working with add_settings_sectionAbout the naming, I got the impression from the documentation that they were meant to be the same.
Forum: Hacks
In reply to: add_options_page slug not working with add_settings_sectionThank you! This worked 🙂
Forum: Hacks
In reply to: add_options_page slug not working with add_settings_sectionanyone got any ideas?
Forum: Hacks
In reply to: Show menu items automatically when posted inI made a bit of progress before you replied, I now have it displaying the categories as main items using this:
add_filter( 'wp_nav_menu_objects', 'roshans_add_populates_categories',10,2); function roshans_add_populates_categories( $items, $args ) { if( $args->theme_location == 'primary' ){ //if we are here, we are in the primary menu //get all top-level categories $args = array( 'orderby' => 'name', 'parent' => 0, 'hide_empty' => 1, ); $categories = get_categories( $args ); foreach ( $categories as $category ) { $url = get_category_link( $category->term_id ); $nav_item = array ( 'title' => $category->name, 'menu_item_parent' => 0, 'ID' => 999999999999876, //an unlikely, high number 'db_id' => 999999999999876, //an unlikely, high number 'url' => $url ); $items[] = (object) $nav_item; } } //back to all menus again return $items; }I know I still need to make the ID’s unique, you say I can do that with
in_array()orarray_key_exists()(and presumably a random number)
Viewing 4 replies - 1 through 4 (of 4 total)