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];
You can explode URL by ? and take the first part: $url = explode( ‘?’, esc_url_raw( add_query_arg( array() ) ) ); $no_query_args = $url[0];
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
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 );
If there were only relative URLs, what would they be relative to? A post can be viewed in several different contexts, including a feed, and a WordPress install can move into a different directory relative to root. There are issues with doing it either way, absolute URLs just give you a more concrete starting point … Read more
is there a way to update all media urls in wordpress I had a similar issue with my media files not having the correct file location after a WordPress upgrade (somehow all the media links switched to a crazy incorrect directory), so I found Upload URL and Path Enabler which was able to rewrite all … Read more
This is an old post but can’t you just use wordpress $menu and/or $submenu globals like Oleg suggested in number 2. When in doubt copy WordPress: wordpress/wp-admin/menu.php For example to add link this seems like it would work: function add_external_link_admin_submenu() { global $submenu; $permalink = admin_url( ‘edit-tags.php’ ).’?taxonomy=category’; $submenu[‘options-general.php’][] = array( ‘Manage’, ‘manage_options’, $permalink ); … Read more
Kind of depends on where you are in the WordPress environment. Plugins If you’re in a plugin, you can use plugins_url. <?php $url = plugins_url(‘css/admin.css’, __FILE__); The above will give you the path relative to the file passed into the second argument. So if you’re in the main plugin file you might get something like … Read more
1) The GUID is exactly that — a GUID. It’s used to uniquely identify the post. If you need to link to a post, then use get_permalink( $post_ID ) ($post_ID is optional) (link: get_permalink). 2) Not without a plugin, no. There’s talk of using an image shortcode for 3.1 though, or maybe 3.2. In the … Read more
You can use wp-config.php to change the site url depending on where the site is accesed from, using $_SERVER[‘REMOTE_ADDR’]. Mine has something like this: if ($_SERVER[‘REMOTE_ADDR’] == ‘127.0.0.1’ || $_SERVER[‘REMOTE_ADDR’] == ‘::1’) { // accesing site from my local server define(‘WP_SITEURL’, ‘http://localhost/mysite/’); define(‘WP_HOME’, ‘http://localhost/mysite’); } else if (strpos($_SERVER[‘REMOTE_ADDR’],’192.168.0.’) !== false) { // accesing site from … Read more
From the Codex entry for Data Validation: URLs: esc_url( $url, (array) $protocols = null ) (since 2.8) Always use esc_url when sanitizing URLs (in text nodes, attribute nodes or anywhere else). Rejects URLs that do not have one of the provided whitelisted protocols (defaulting to http, https, ftp, ftps, mailto, news, irc, gopher, nntp, feed, … Read more