Is it possible to create dynamic endpoint URLs?

add_rewrite_endpoint() only supports static endpoint names like trackback and recipes, so if you need a dynamic endpoint name/slug, then you would want to use add_rewrite_rule() instead. And just so that you know, even if add_rewrite_endpoint() did support dynamic names/slugs, your code would not work because your function runs too early (via the init hook) and … Read more

Custom Download Link

Do you just need to redirect that one specific request (for /wp-content/uploads/2010/12/history.pdf to /about/history.pdf)? Or do you need to to handle many requests (say, for /wp-content/uploads/2010/12/* to /about/*)? If it’s the former, use a symbolic link (or, if you’re not on Unix/Linux/BSD, whatever equivalent your OS offers). If it’s the latter, use mod_rewrite (or, if … Read more

Rewrite vs Redirect from ?p={ID}

A rewrite enables http://example.com/post-title/ to translate internally to the proper query vars to load the requested post. The shortlink does a 301 redirect to the pretty URL because it should not be possible to access the same content from more than one URI. This is so a search engine won’t index the same post under … Read more

Custom URLs in Custom Search Results

You can get close to what you want by using the template_redirect hook. function my_custom_search_url_rewrite() { if ( is_search() && ! empty( $_GET[‘s’] ) ) { wp_redirect( home_url( “/search/” ) . urlencode( get_query_var( ‘s’ ) ) ); exit(); } } add_action( ‘template_redirect’, ‘my_custom_search_url_rewrite’ ); Then you can use a URL like http://domain.com/search/category+location/. If you then … Read more

How to rename custom taxonomy URL with extra words

You’d be better off adding or modifying the rewrite variable that’s being passed to your register_taxonomy() call for the custom taxonomy. You can modify the rewrites to suit your purpose. For example: $taxonomy_args = array( // All the variables and their values… ‘rewrite’ => array( ‘slug’ => ‘services/home-care’, ), // …more variables and values… ); … Read more