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];

Load images with http urls inside https post

It’s a fairly common issue when you update your WordPress site’s URL form HTTP to HTTPS or if you are migrating to a new domain. While a partial solution is to update your WordPress’ home and site URL in your settings: That doesn’t mean that the new URL structure in your posts will be fixed. … Read more

How to check if feed URL was requested?

You have not specified exactly when your code runs but you can hook into “request” to check the requested page: add_filter( ‘request’, function( $request ){ if( isset( $request[‘feed’] ) ){ //This is a feed request } return $request; }); When the requested page is a feed $request, which is an array of query variables, will … Read more

Get taxonomy slug from url

I think you are looking for get_query_var $term_slug = get_query_var( ‘term’ ); $taxonomyName = get_query_var( ‘taxonomy’ ); $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName );

Removing hierarchical pages in the permalink

I’d be curious if someone can find a better solution to this. Here’s what I came up with: function wpse_91821_flatten_page_paths( $wp ) { if ( false !== strpos( $wp->matched_query, ‘pagename=” ) && isset( $wp->query_vars[“pagename’] ) && $wp->query_vars[‘pagename’] && false === strpos( $wp->query_vars[‘pagename’], “https://wordpress.stackexchange.com/” ) ) { if ( !get_page_by_path( $wp->query_vars[‘pagename’] ) ) { $page = … Read more

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