Adding another word in front of post url
You can do it from Settings > Permalinks. Select the Custom Structure radio button, and put this in the text field next to it: /myspecialword/%postname% Works.
You can do it from Settings > Permalinks. Select the Custom Structure radio button, and put this in the text field next to it: /myspecialword/%postname% Works.
The problem as @Indolering mentioned is related to URL Rewrite module that the URLs containing UTF-8 characters is not correctly passed when processed by the URL Rewrite module. Because I’m not the server owner and I’m unable to install the mentioned hotfix (even though I’m using IIS8.5 the problem is still existed) I had to … Read more
You can do the following: /* add new rewrite rule */ function attachment_rewrite( $wp_rewrite ) { $rule = array( ‘media/(.+)’ => ‘index.php?attachment=” . $wp_rewrite->preg_index(1) ); $wp_rewrite->rules = $rule + $wp_rewrite->rules; } add_filter( “generate_rewrite_rules’, ‘attachment_rewrite’ ); /* redirect standard wordpress attachments urls to new format */ function redirect_old_attachment() { global $wp; if( !preg_match( ‘/^media\/(.*)/’, $wp->request ) … Read more
You will need to intercept the links generated by WordPress and append the query var onto the relevant URLs. You can do this quite easily with a filter on category URLs with something like… function add_my_query_var( $link ) { $link = add_query_arg( ‘sort’, ‘most_voted’, $link ); return $link; } add_filter(‘category_link’,’add_my_query_var’); I also spotted this handy … Read more
$_SERVER[‘REQUEST_URI’] will not be empty in WordPress, because it is filled in wp_fix_server_vars() (file wp-includes/load.php). This function is called in wp-settings.php before any plugin is loaded. So you can use it. But always escape the value. It is global and can be changed by any other code, so you cannot trust its value. A different … Read more
$my_url=”my/relative/url.php”; echo site_url($my_url); site_url() when used by itself will return the absolute path to your blog. But, if you add an argument to it, as per my example above, it will prepend the absolute path to your path. Just make sure your URL doesn’t contain a leading slash (eg: /this/may/not/work). Finally, if you happen to … Read more
It depends on your image and stylesheet location. But this is the syntax: .theme-image { background-image: url(‘../images/header-img.jpg’); } The above code is for the structure wp-content – themes – your-theme – images – header-img.jpg – css – style.css You are making the browser come one directory before and search for images directory.
Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code: function set_my_nice_name() { global $wpdb; $user_table = $wpdb->prefix . ‘users’; $wpdb->query(“UPDATE $user_table SET `user_nicename`=`ID`”); } add_action(‘init’, ‘set_my_nice_name’); This works because the visible portion of an author slug (or profile slug in BuddyPress) uses the user_nicename … Read more
Okay… here’s how you add the rule. <?php add_action(‘init’, ‘add_my_rule’); function add_my_rule() { add_rewrite_rule(‘^test\/link.*$’,’index.php?pagename=about’,’top’); } ?> This rule will ensure that when you visit a url like http://…/test/link or http://…/test/link<xyz>, you are redirected to the about page (please make sure the slug for about page is ‘about’). Also, http://…/test/, will take you the test page … Read more
I did something similar recently. 1. If the user is not logged in I captured the desired/destination page’s URL and added it as a query arg to the login page’s URL. 2. Redirect the user to the login page. function wpa_59205_redirect(){ global $post; if ( ! is_user_logged_in() ) { // this will tack on the … Read more