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

Adding pretty query parameters

You would need a custom rewrite rule for that: http://codex.wordpress.org/Rewrite_API/add_rewrite_rule I think you might have a hard time though, with it being within an area of the site (single post type) already using a custom rewrite rule!

How do I change attachment slug from name to id

Use the add_attachment hook to update the slug after the attachment has been inserted: function wpse_182454_attachment_id_as_slug( $post_id ) { if ( get_post_field( ‘post_name’, $post_id ) != $post_id ) { wp_update_post( array( ‘ID’ => $post_id, ‘post_name’ => ( string ) $post_id, ) ); } } add_action( ‘add_attachment’, ‘wpse_182454_attachment_id_as_slug’ );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)