I run a non-English blog. I love that WordPress has been translated to Spanish and currently I use the Spanish translated version of WordPress.
One thing that I'd really like to change is the URL structure for my blog. For example, instead of sitio.com/category/gatos
, I'd like to change the URL to sitio.com/categoria/gatos
. I know you can set the category base and tag base in Settings/Permalinks, but I'd like to know how to do this in code. Also, I want to translate search/
to busqueda/
and page/
to pagina/
.
I want to translate all of these to Spanish.
- category_base
- author_base
- pagination_base
- feed_base
- search_base
- comments_base
I'd like to be able to make these this just within my own theme (that I've made from scratch), that way these changes could be more portable.
I've read the WordPress Codex for WP_Rewrite
and have experimented with add_rewrite_rule
, but I'm still stuck. Does anyone know where else I could look?
Update:
With this function, your search form can still use name="s"
, but the user will be redirect to the appropriate location on submit.
function redirectSearch()
{
// Make sure you redirect to whatever your search_base is.
if(!empty($_GET['s'])){
wp_redirect(home_url('/busqueda/').urlencode(get_query_var('s')));
}
}
add_action('template_redirect', 'redirectSearch');