Permalinks for custom taxonomy stopped to work

Sometimes a plugin changes WordPress’ internal rewrite rules during an update, an installation or deactivation. If the plugin’s update happens to run after your taxonomy registration it may just wipe out the custom rules for the taxonomy. To inspect the currently active rewrite rules use the plugin Monkeyman Rewrite Analyzer. See this answer for details. … Read more

How to define a callback for an URI?

You can use add_feed( $url, $callback ). Despite its name it sends a text/html Content-Type. Basic example: add_action( ‘init’, ‘wpse_50841_register_extra_page’ ); function wpse_50841_register_extra_page() { add_feed( ‘wpse50841’, ‘wpse_50841_callback’ ); } function wpse_50841_callback() { print ‘<p>It works!</p>’; } Visit the permalink settings page once to refresh the rewrite cache, and go to example.com/wpse50841/ or example.com/?feed=wpse50841 to see … Read more

How to remove parent section from attachment URL?

The attachment URL is created in wp-includes/link-template.php in function get_attachment_link(). And there is a filter for you, passing the WordPress URL and the post id for the attachment. You can hook into that filter and return the URL you need: add_filter( ‘attachment_link’, ‘wpse_56619_unprettify_attachment_url’, 10, 2 ); function wpse_56619_unprettify_attachment_url( $link, $id ) { return home_url( “/?attachment_id=$id” … Read more

Creating a dynamic URL structure

Demonstrated here: http://thereforei.am/2011/10/28/advanced-taxonomy-queries-with-pretty-urls/ Here’s the final code to autogenerate the necessary rules: It’s quite likely you will at some stage want to programmatically generate rewrite rules for multiple custom post types with various taxonomies. You could do it manually, but that’s no fun. Let’s use an automatic rewrite rule generator. The function below takes a … Read more

Changing RSS feed URL structure

After some thought – this can be achieved with some creative abuse of existing feeds: easy part – redirect category feeds to page comment feeds hard part – make page comment feeds think they are category feeds Something like this: Category_Feed_At_Page::on_load(); /** * Repurpose page feeds for category of same name feeds. */ class Category_Feed_At_Page … Read more