Flushing rewrite rules

What flush_rewrite_rules(); does is call $wp_rewrite->flush_rules(); (Also called when updating permalinks). All plugins rewrite rules are regenerated then, so you dont need to worry about other plugins rules being “missing”. Also is not a good idea to call this function (flush_rewrite_rule) on hooks that run each time wordpress is loaded, and is enough to call … Read more

Clicks registering on Preview DNS site

It appears that you have content (pages, posts or widgets) that contain old URL information. An example of a URL that is correct: http://www.hutchisonhaines.co.uk/wp-content/themes/FactoryWP/style.css An example of a URL that is incorrect: http://hutchisonhaines.co.uk.previewdns.com/wp-content/uploads/2012/02/flowers-944×290.jpg The quickest way to fix this problem would be to do a database dump and then run a search and replace program … Read more

How to get CGI variables?

First off, these aren’t CGI variables, they’re query string arguments. WordPress, by default, will remove any query arguments that it doesn’t recognize. So you need to register them with WordPress and then pull them back out of the query. First, add your new query variable: function wpa_48528_vars( $vars ) { $vars[] = ‘filter’; return $vars; … Read more

Problem with parent page slug only in WordPress admin

Edit. Here’s another solution to not mess with the edit slug button. The function get_sample_permalink_html in wp_admin/includes/post.php outputs the sample permalink and an edit button. It can be filtered like this: add_filter(‘get_sample_permalink_html’,’my_sample_permalink’,10,2); function my_sample_permalink ($page_link,$id){ $page = get_page($id); if($page->post_type == “page” && $page->post_parent) { $parent = get_page($page->post_parent); $page_link = preg_replace(“/(sample-permalink\”>).*?(<)/”,”$1″.home_url(“https://wordpress.stackexchange.com/”).$parent->post_name.”/$2″,$page_link); } return $page_link; } Can’t … Read more

custom wordpress rewrite

WordPress has two kinds of rewrite rules- internal and external. Internal rules are parsed by WordPress and routed to index.php. External rewrites get written to .htaccess and are not directed to WordPress. Right now your rule is a mix between internal and external- you have it structured as an internal rule, but you have it … Read more

Change URLs depending on alias

You can use the the WP_HOME directive in your wp-config.php. Just set it dynamically based on $_SERVER[‘HTTP_HOST’] like the example in the codex. <?php define(‘WP_HOME’, ‘http://’ . $_SERVER[‘HTTP_HOST’]); You might also want to define WP_SITEURL in the same way. I do something like the above for the wp-content url on one of my sites: <?php … Read more

Nicer URL for viewing category of posts?

If you want to remove the /category/ base from wordpress urls then I recommend that you use WP No Catgeory base plugin Quote from plugin discription – This plugin will completely remove the mandatory ‘Category Base’ from your category permalinks e.g. myblog.com/category/my-category/ to myblog.com/my-category/

What can I replace ‘.get_bloginfo(‘url’).’ with to return the current URL rather than the home address?

A quick Google search lead me to this little gem from a blog post by Konstantin Kovshenin: global $wp; $current_url = add_query_arg( $wp->query_string, ”, home_url( $wp->request ) ); Combine that with your original code, and you have this (updated to match the WordPress coding standards): function show_theme_switch_link_func( $atts ){ global $shown_theme, $status, $wp; $desktop_switch_link = … Read more

How can I do a url redirect to include a wordpress username?

You have to add action to, for example, template_redirect action hook. The action would perform your desired checks and redirect user using the wp_redirect() function. The code could look something like this: function my_redirect_function() { // Check if home page is being displayed if ( is_home() ) { global $userdata; get_currentuserinfo(); $username = $userdata->user_login; $url=”http://my.url.org/mentions/” … Read more