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?
- How to Customize the Admin Sidebar Menu in WordPress Multisite Network by changing the backend code of the wp-admin code files?
- Menu Limitations
- Namespace spl_autoload problem in WordPress admin
- How can I Add a variable PHP in the Menu Nav
- Where to place PHP code that inserts (or doesn’t insert) menu item?
- Unreadable pagination
- remove wp floating submenu in wp dashboard
- Adding an Avatar to the Top Nav Bar
- My custom wp-admin php files stopped working
- Add data attribute to each li in menu
- Call to undefined function wp() in wp-blog-header.php
- Cannot access wp-admin (wordpress dashboard)
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- How to add an arrow to menu items has submenus
- How to make my custom widget appear within WordPress widgets? Plugin development
- 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
- Child page menu in sidebar
- Replace part of a parent-theme customizer in the child-theme
- Title Case WordPress Menu Items
- PHP version problem?
- Secondary navigation menu on one page
- Remove class in nav_menu_link_attibutes filter
- Programmatically create page when saving custom post type post
- WordPress admin is incredibly slow [closed]
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- inserting a post from an extern php file but post content doesn’t show on wp site
- How to change menu order item
- two columns of posts on homepage, one of them “favorites”
- How to edit php files in Child Theme?
- WordPress Child Themes
- Custom Menus: dynamic highlighting problem with custom home link
- get_the_title() gets printed out twice
- How to change menu labels
- Custom Background by Page IDs
- Copyright info change – Corporate Plus Theme PHP [closed]
- Add item to top of menu using a filter in functions.php
- WordPress admin-ajax.php
- Adding PHP in the menu
- Two menus show up
- Why is only the first operation run in my loop – except for on the last repeat? [closed]
- How can I open up my administrative panel to everyone?
- How do I modify the custom footer text and get theme version number to show in wordpress admin?
- Started getting warning message following host’s PHP upgrade
- Register a menu – Error Header
- How to style one item from main navigation?
- WordPress ajax-action failing because of newline in response
- Show About and Contact Us page when they’re clicked in the top menu.
- get_total () returns 0 – woocommerce [closed]
- Add data-id attribute to child page links
- Parsing Menu Items and Blog Posts
- Link blogname and blogdescription to the Options Framework
- retain querystring values when savincustom options in admin
- Usage of call back function of add_meta_box()
- Automatically add images to a menu
- Why does the Woocommerce grouped template prints the unpublished products?
- AJAX wp_insert_user WORKS but responds with “The site is not enabled”
- How to edit HTML of my website on WordPress? [closed]
- Divi change project category slug
- WordPress wp-admin redirect and exception
- How to specify the path for require_once in a child theme?
- Warning: printf(): Too few arguments in helpers.php file
- What’s a good way to allow overwriting files within a child theme if I want the same folder structure?
- WordPress filter load_textdomain_mofile not working inside a child theme’s functions.php but works form inside a plugin
- How do I check or test a WordPress Auto Year Change Script?
- Use custom template on custom post type
- Add value to new attribute inside WordPress menu items
- How to have different site identity logos on each page on Astra Theme [closed]
- wp_nav_menu not working correctly in my underscores theme
- Include style.css in the Child Theme with PHP
- Override Admin menu icon
- Using admin-post.php for admin form but it directs me to admin-post.php white screen
- Menu Items fail to save correctly, cause reset of related page metadata
- Dropdown menu for categories
- Menu Custom Data Attributes
- Get the name of menu item with wp_nav_menu