Porting site URLs to new host but with same domain name [closed]

This is probably because .htaccess is not being respected. If you’re using Apache as a webserver, make sure that mod rewrite is active and .htaccess files are read and used in vhosts. You should allow overrides in the vhost. Like this: <Directory /var/www/site/example.com/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> If you are … 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

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

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

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

How to parse a custom url (within WP site) and obtain params passed to that URL

First, you register your query vars param1 and param2: function wpse_101951_query_vars( $qv ) { $qv[] = ‘param1’; $qv[] = ‘param2’; return $qv; } add_filter( ‘query_vars’, ‘wpse_101951_query_vars’ ); To use this information, you can pretty much hook into any action or filter after parse_query. That’s the first action available after the query vars are set, so … Read more

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