You can extend it, but the class definition and any code that uses it, can’t run outside of the admin area.
Wrap your class in this conditional:
if ( is_admin() ) {
...
}
If you are trying to use this on the frontend or other non-Admin areas, do not do that.
Generally, classes WordPress uses should not be extended, walker classes and WP_Widget
are the notable extensions.
Also, it’s good practice to put classes in their own files.
Related Posts:
- Mega Menu Walker
- start_lvl Ignored in Custom walker_nav_menu
- Walker class: Problems with understanding how walk() method can be called without error
- Run a filter when a walker runs
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- WP Walker using custom css classes
- Automatically adding new post categories to menu
- Remove metabox from WordPress menu editor page?
- Custom Walker_Nav_Menu issue with variables on PHP 7.3
- Trying to store submenu items to render out after main menu
- Detecting classes, adding widgets, and adding divs in with a Nav Walker
- New walker for walker_nav_menu to change inside container data
- Add login hyperlink to secondary navigation menu
- How to display different submenus?
- Extend Menu Walker Output
- Nav Walker that shows only children and siblings of top level parent menu item
- Adding markup to sub menu based on class
- How to let mobile navigation menu close when link is clicked?
- How to disable sub menu items from being created?
- Difference between “Walker_Nav_menu” and “walker”
- Add parent menu item in sub-menu in custom nav_walker
- Add the “.current-menu-item” class to tag?
- Custom Links in Walker Class
- I am extending Walker_Nav_Menu: How can I get the number of children elements of the current item?
- Adding first / last CSS classes to menus
- Is it possible to disable a function of a parent theme?
- how to put the logo in the center of other items in the navigation bar
- Jquery no more loading, load-scripts.php not found (404)
- Site Title and Tagline in Pagelines DMS Options Panel
- Enqueue Javascript Correctly for 3.5
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- Can we have a php “page” without a WordPress “page”?
- Add footer.php to WordPress child theme
- wp_delete_auto_drafts() deletes links in menus
- How to override a non pluggable and non hookable function in a WordPress parent theme?
- Logout and redirect using the WP Menu
- Creating new menu item
- Indirect modification of overloaded property WP_Post::$classes has no effect
- Programmatically create menu with custom link
- Custom Loop through category menu to include sub categories
- List User order by ID in Descending order (Backend)
- JQuery not working on WordPress Admin page [closed]
- Admin username and password
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Change Navigation Bar based on logged in or not
- Retrieving Author ID in wp-admin area
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- How to create a form and display its content as table in admin panel?
- How can I Add a variable PHP in the Menu Nav
- Adding an Avatar to the Top Nav Bar
- Add data attribute to each li in menu
- How to add an arrow to menu items has submenus
- wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu
- Unique icons next to each WordPress menu item
- inserting a post from an extern php file but post content doesn’t show on wp site
- How to edit php files in Child Theme?
- Add data-id attribute to child page links
- How to specify the path for require_once in a child theme?
- Warning: printf(): Too few arguments in helpers.php file
- How do I check or test a WordPress Auto Year Change Script?
- Notice: Trying to get property of non-object
- WordPress redirects to old login after migration
- How to use wp_nav_menu to create custom dropdown menu?
- Nav-Menu not showing up
- Need advice on theme customizer and child themes
- How to tell if a user has gone in and created a menu
- Hard-coding a shortcode as the last menu item in primary navigation?
- Help with accessing wp-admin page and resolving error messages
- Add class to ul and li in wp_na
- how to changes mobile menu toggle breakpoint in WordPress
- How to display already created menus via php?
- remove_action from parent theme using child theme functions.php
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Hide Approved status for certain users in users list
- wordpress contact form messages not sending although it saying they were sent successfully with this php code
- Save custom field on WP_List_Table
- Create “blank” admin page without having admin-bar/admin-menu for faster load
- Editing the term_order field
- Add element after navigation element title don’t works like I expect
- If i use a child theme to add new code blocks to header.php, how does it get inserted in the right place in parent’s header.php?
- How to override html codes in wordpress?
- How to create a sub-page of sub-page?
- wp_query beginner
- Adding custom PHP to existing loop in Genesis
- Widget Logic – display on page and all child
- How to list categories by page id in wordpress
- Adding button to wordpress menu
- Child theme functions.php file change database entries
- wp_nav_menu doesn’t work in a duplicate server
- How I can add div to menu?
- Add options to WordPress backend
- How to get the count for each taxonomy term
- WP_Nav Highlight Parent Issue
- admin-ajax.php loading many times
- Change order that the menu is generated with wp_list_pages
- What’s the .php file which generates the Custom Background page in the admin panel?
- How to replace wp-admin login page to another location?
- Add Woocommerce Customers link to custom admin menu
- Custom nav with bootstrap dropdown