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

Organizing the Navigation Menu

Check nav menu target URL for ‘/pressroom/’, then check if it’s a post. If it fits, add custom class to that menu item. <?php function my_add_posts_page_ancestor_class( $classes, $item ) { if( false !== strpos($item->url, ‘/pressroom/’) && is_single($item->ID) && !is_page($item->ID) ) { $classes[] = ‘my-ancestor-class’; } return $classes; } add_filter(‘nav_menu_css_class’, ‘my_add_posts_page_ancestor_class’, 10, 2); The code is … Read more

wordpress url correction

Copy the index.php and .htaccess file(Just copy it , do not move it ) from myblog directory to root directory. Open index.php file in any text editor and find the following code in the file. /** Loads the WordPress Environment and Template */ require(‘./wp-blog-header.php’); Replace it with the following code and save the file. /** … Read more

Post’s ID pattern?

Each auto-draft gets its own ID, each revision, each nav item, page, custom post type … The actual ID of a post should be irrelevant, this is really just needed for the database and ugly permalinks. You cannot get the last 30 items by inspecting the post ID only. Install a REST API on the … Read more

How to remove the number of a comment in the url slug?

The asker solved the issue with $_SERVER[“HTTP_REFERER”] but refused to post that as a real solution. Let me suggest something better, because the referer might be empty or full of malicious code. Never use that. First, we make sure, we get both arguments for that hook: add_filter( ‘comment_post_redirect’, ‘wpse_97580_comment_redirect’, 10, 2 ); Then we use … Read more

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