Your original solution was a hack, and no surprise it failed. In general never add methods/attributes to objects that you do not control their class and future development.
The right way is to create your own object to be passed to the walker. Pass to it the category object on construction and either populate fields is a similar way to the category object or write accesor functions for it (for full hacking points use _get()
and _set()
😉 ). Design it good enough and your walker code will not have to change at all, only the initialization.
Related Posts:
- How can you receive the most recent permalink or terms of the newly saved post?
- How can I get this custom post type permalink structure? %custom_post_type%-%taxonomy%-%term-postname%
- MySQL-inserted custom taxonomy term lead to 404, flush rewrites doesn’t help
- Pretty permalinks for search results with extra query var
- Does WordPress automatically do 301 redirect if I change permalink
- Regex in add_rewrite_tag not accepting OR operators?
- Pretty Permalinks
- Remove parent slug for child pages
- How to display comments on different page
- Limiting the number of words or characters in the slug/permalink
- How to change URL structure for pagination pages?
- custom naming of search permalink /search/
- Why WordPress Can’t Handle site.com/%postname%/someword ? Gives 404
- Is it possible to list post attachments in a sub URL endpoint with a dedicated template?
- How to edit the slug/permalink in Gutenberg?
- How can I get the permalink of a post before it is published?
- Add a URL prefix to permalinks of News category and sub-categories of posts only
- How to achieve a clean custom permalink solution?
- How can I make my .htaccess file writeable by wp-admin?
- Custom taxonomy rewrite using tax name instead of rewrite slug
- Custom add_rewrite_rule & permalinks
- How do I get all the URLs from my WordPress site?
- Custom query var rewriting with only variable
- Date Archives’ Permalinks under Category folder
- add_rewrite_rule not working for me
- Using WP Rewrite, but just not “getting it”
- List / Get post redirects
- Permalinks problem – Category pages don’t work
- Rewrite CPT permalinks and include WPML language
- Need To Add Custom rewrite base url for individual user
- example.com/index.php/%postname is working while /%postname is not working WordPress on IIS6
- 301 Redirect for Non-Date Based URL’s
- WordPress is suppressing page extensions!
- Strange number at the end of wordpress permalinks
- Custom permalink structure gives 404
- Category with the same slug
- Do WordPress Permalinks Refer to a Lookup Table in the Database?
- Permalinks settings
- Changing permalinks structure without loosing SEO
- Change Structure Permalink => Error 404? How to redirect
- Change Buddypress Admin Profile Page Permalink
- how do links move when I move my site?
- Permalink for specific page name
- Permalink for PDF of article
- get_posts post title permalink not working for last item in array
- Comment author url link is wrong? How to change from authors/ to author/
- Why can’t change the permalink of my page/post?
- Direct link to post when multiple categories are selected
- Add post overwriting permalink from previous post in 4.6
- Make custom post available under main domain directly?
- Getting an ID from a URL, why can WP do this itself, but none of of the functions provided get it right?
- Add variables to all permalinks in site
- Big arabic permalinks not work
- Fix 404 error after changing permalink structure
- How can I set up a secondary permalink structure?
- External PHP file & Pretty Permalink
- What is the right way to clean up $title before wp_insert_post?
- How to get links to user and tag by its name?
- Help me fix these crazy attachment page URLs (rewrite?)
- Unable to rename permalink
- WordPress permanent links not working (the weird way)
- How to Use metada Value in Url and is it possible? [duplicate]
- How to enable %postname% permalinks on Mac?
- How to allow slash(/) on page url
- Safest way to create a custom permalink
- How do I structure my permalinks in WordPress?
- WordPress wildcard route to page
- An excluded ‘ghost’ page is crashing my permalink
- WordPress Attachment Page URL Rewrite!
- Customize URL for specific tags archive
- Yoast and permalink troubleshooting
- Permalink Issue | Too many redirects
- Permalink prefix change
- WordPress project redirecting to a blank index.php when i use custom templates
- Parent/Child Relationships with Multisites?
- Custom Permlinks work, regular page permalinks don’t
- How to redirect from old standard wordpress permalink structure to new custom one
- Rewrite posts url as they’re all children of a page
- wp_dropdown_categories links 404
- Permalink problem ( Blog posts vs custom post types)
- Two urls for one website
- Added incorrect rewrite rule now getting an error
- Keep wordpress from modifying my permalinks
- get_permalink wrongfully returns only year and month and not all the link
- How to retrieve the permalink for a specific (custom) term?
- Link to most recent child page
- Permalink Rewrite to include Custom Taxonomy Term
- Automatic -1 suffix being added to the permalinks of a page when the page does not exist
- Permalink Issue – Funny & Weird
- WordPress permalink still not working (error or not understood?)
- Pagination is not working, how to trace it properly?
- Problem when i configure permalink
- Getting the top level permalink using get_post_ancestors()
- Files placed in directory with wordpress 404
- wordpress home is gone
- how to create several url aliases for a page
- Post URL not working according to permalink setting
- Strip category base from URL?
- Does the error “A structure tag is required when using custom permalinks.” mean my permalinks haven’t saved?
- Settings > Permalinks – mod_rewrite ineffective if expression not preceded by /index.php/