How to prevent redirection to max 2147483647 for larger values of the page query variable?

The Why Part If we have a page called technical and try to load: example.tld/technical/99999999999999999999 then the 99999999999999999999 part is treated as a page query variable with the value of 2147483647. The reason is this rewrite rule for pages: according to the handy Monkeyman Rewrite Analyzer by Jan Fabry. This part of the WP_Query::get_posts(): if … Read more

Multisite – sub-subfolders for certain blogs

In order to do partition your blogs like this you’re going to need to write a custom plugin similar to the WordPress MU Domain Mapping plugin. Here’s how your plugin needs to work. Create a sunrise.php file for your plugin, and properly define(‘SUNRISE’,true); in your wp-config.php file. Create a table which maps the tuples {blog_slug, … Read more

Allow admin login at /admin

another option – redirect /admin/ to wp-login.php with a parse_query action hook: function wpa53048_parse_query( $query ){ if( $query->query_vars[‘pagename’] == ‘admin’ ): wp_redirect( wp_login_url() ); exit; endif; } add_action( ‘parse_query’, ‘wpa53048_parse_query’ ); EDIT Well the above apparently only works with certain permalink structures. Here’s another method hooked to parse_request: function wpa53048_parse_request( $query ){ if( $query->request == … Read more

Hook for URL Request

Actually, my recommendation would be to do things a bit differently. You can add a custom rewrite endpoint to WordPress to handle these files specifically. For example, the URL http://site.com/download-xml/the_filename would automatically download the specified file as an attachment. First, you need to add a custom rewrite endpoint to set this up: function add_endpoint() { … Read more

why does anchor name add a slash to url?

It is okay that the URL changes to http://mysite.com/contact/#rocket, but you should change the way you are defining your anchor on the target page. Instead of using this method <a name=”rocket”></a> <div> <h3>The Title</h3> <p>some text</p> </div> You should add an ID to the content you want to jump to like this: <div id=”rocket”> <h3>The … Read more

Update URL Snippet to Canonical Permalink URL

Why? I think the reason why a) domain.com/123 is not redirected back to b) domain.com/123/post-slug with the /%post_id%/%postname%/ permalinks settings, is that the matched rule is: [matched_rule] => ([0-9]+)(/[0-9]+)?/?$ You can get that information from the global $wp object. There are other useful informations in $wpavailable after the wp action: Example (post): domain.com/123/post-slug/ [query_vars] => … Read more

Remove All Query Arg

You can explode URL by ? and take the first part: $url = explode( ‘?’, esc_url_raw( add_query_arg( array() ) ) ); $no_query_args = $url[0];