Multilingual theme: Changing locale based on URL

My problem here is that get_query_var(‘language’) isn’t defined in the function set_my_locale Because get_locale (which applies the filter locale) is called before wp() (which parses the query & sets up the variables). You’ll have to manually inspect the request yourself: if ( strpos( $_SERVER[‘REQUEST_URI’], ‘/de/’ ) === 0 ) { // German } else { … Read more

Dynamically redirect page based on URL?

Assuming you stick with add_rewrite_rule(), if language and title where set as meta data on the /en/ post, then you can simplify the search down to a simple WP_Meta_Query() for /:lang/:title/ and pull the actually ID of the translated post there. Translations for /en/best-restaurants-in-tokyo: “/it/migliori-ristoranti-a-tokyo” => 4016 “/fr/meilleurs-restaurants-à-tokyo” => 4017

redirect 301 old url to new url

Well, you would have to add some re-write rules in your .htaccess file (unless there’s a plugin that can allow more complex 301 redirect rules). But, in your situation, if I understand correctly, it’s simply not possible to do it in one generic rewrite rule, due to the logic of your new URLs… If all … Read more

Change permalink for default archive – yearly

It should work but note that the date structure contains the structure for year, month and day archives as well, so you’ll need something like: add_action( ‘init’, function() { global $wp_rewrite; $wp_rewrite->date_structure=”archives/%year%/%monthnum%/%day%”; }); Don’t forget to visit your permalinks settings page in wp-admin so that rewrite rules are flushed.

Rewrite URL to remap WordPress Permalink

The most efficient way to accomplish this would be to change the structure to /%postname%/ and add a 301 redirect to your .htaccess file for the old structure: RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ http://example.com/$3 Change example.com to your domain and add the redirect above the # BEGIN WordPress directive so it won’t be removed if WordPress updates … Read more

Display content according to current URL

For this to work, you would have to add a rewrite that rewrites https://example.com/[manufacturer slug]/[brand slug] to index.php with e.g. manufacturer=[manufacturer slug]&brand=[brand slug]. e.g.: add_filter( ‘rewrite_rules_array’,’jf_insert_rewrite_rules’ ); function jf_insert_rewrite_rules( $rules ) { $newrules[‘^(.*)/(.*)/?$’] = ‘index.php?manufacturer=$matches[1]&brand=$matches[2]’; return $newrules + $rules; } Remember to goto permalinks page and hit save for the rewrite rules to be updated. … Read more

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