I’m having issues getting my WordPress page URLs to show the category. I’ve tried setting up a custom structure in the permalinks settings with /%category%/%postname%/, but it’s not working as expected. The postname shows up fine, but the category part is missing.
I’m running the latest WordPress version with just one plugin (Events Manager). I’ve also added some code to my functions.php file to enable categories for pages:
function add_taxonomies_to_pages() {
register_taxonomy_for_object_type('category', 'page');
register_taxonomy_for_object_type('post_tag', 'page');
}
add_action('init', 'add_taxonomies_to_pages');
I’ve tried clearing the cache and refreshing, but no luck. The URLs still don’t include the category. Any ideas on what might be causing this or how to fix it? I’m stumped and could really use some help figuring this out.
I’ve encountered similar issues before, and it can be frustrating. One thing to check is whether your pages are actually assigned to categories. Unlike posts, pages don’t have categories by default, even with the code you’ve added to functions.php.
Try this: go to one of your pages in the WordPress admin, and look for a ‘Categories’ box in the right sidebar. If it’s not there, you might need to enable it via Screen Options at the top. Assign a category to the page and update it.
If that doesn’t work, there might be a conflict with your theme or the Events Manager plugin. Try temporarily switching to a default theme like Twenty Twenty-Three and disabling the plugin to see if it resolves the issue.
Lastly, double-check your .htaccess file. Sometimes permalink issues stem from incorrect rewrite rules. You might need to regenerate it by resaving your permalink settings.
hey mate, i had the same issue. try flushing ur rewrite rules. go to Settings > Permalinks and just hit ‘Save Changes’ without changing anything. that usually does the trick. if not, maybe check if ur .htaccess file is writable. good luck!
Have you considered that this might be a caching issue? Sometimes, changes to permalink structures don’t take effect immediately due to server-side caching. Try clearing your server cache if you have access, or ask your hosting provider to do it for you.
Another possibility is that your theme is overriding the default permalink structure. Check your theme’s functions.php file for any custom rewrite rules or filters that might be interfering with your desired URL structure.
If neither of these solve the problem, you might want to try using a plugin like ‘Custom Post Type Permalinks’ to give you more control over your URL structure. Just be cautious about adding too many plugins, as they can sometimes conflict with each other or slow down your site.
Remember to back up your site before making any significant changes, just in case something goes wrong and you need to revert.