I have a fresh installation of wordpress, and I wrote some quick rewrite rule in my functions.php that looks like this -
// "rewrite" /assets/xyz to /assets/?asset=xyz
function assets_rewrite_rule($rules) {
global $wp_rewrite;
$asset_rule = array( // (not tested)
'assets/(.+)/?' => 'index.php?pagename=Assets&asset=$matches[1]'
);
return array_merge($asset_rule, $rules);
}
add_filter('page_rewrite_rules', 'assets_rewrite_rules');
And I have my sidebar translated with WPML and String Translation in the most primitve way.
Here's the english part (not translated) of my sidebar -
<div class="sideall">
<div class="sidebar-mai1">
<div class="sidebar-name">
<img style="width: 25px; margin-right: 10px; margin-bottom: -7px;" title="first asset" src="/wp-content/images/sidbar-assets/firstasset.png" alt="first asset" />First Asset</div>
<div class="sidebar-btn">
<a class="btn-sidebar" href="/assets/first-asset/">Review</a>
<a class="btn-sidebar1" href="/buy/first-asset">Trade Now!</a></div>
<div style="clear: both;"></div>
</div>
And while trying to make a translation to other language (let's say italian), the wpml refuses to save my changes to the review links..like my redirection rule is affecting it somehow.
Here's the translation I added to the sidebar -
<div class="sideall">
<div class="sidebar-mai1">
<div class="sidebar-name">
<img style="width: 25px; margin-right: 10px; margin-bottom: -7px;" title="first asset" src="/wp-content/images/sidbar-assets/firstasset.png" alt="first asset" />First Asset</div>
<div class="sidebar-btn">
<a class="btn-sidebar" href="/it/assets/first-asset/">Revisione</a>
<a class="btn-sidebar1" href="/buy-it/first-asset">Scambia ora!</a></div>
<div style="clear: both;"></div>
</div>
As you can see both the review and the buy links were changed.. but after I hit save, it only saves the change i made in the buy href, but it reverts my change to the review link, and it looks like this after I save -
<div class="sideall">
<div class="sidebar-mai1">
<div class="sidebar-name">
<img style="width: 25px; margin-right: 10px; margin-bottom: -7px;" title="first asset" src="/wp-content/images/sidbar-assets/firstasset.png" alt="first asset" />First Asset</div>
<div class="sidebar-btn">
<a class="btn-sidebar" href="/it/assets">Revisione</a>
<a class="btn-sidebar1" href="/buy-it/first-asset">Scambia ora!</a></div>
<div style="clear: both;"></div>
</div>
As you can see, after I hit save, it removes the /first-asset part from my translation and now it leads to an empty page (/it/assets) .. I am wondering if it may be cause as a result of the rewrite..