Is it possible to get a Wordpress URL to look like this:
/%post-type%/%custom-taxonomy%/%postname%/
I can get everything but the middle. Any ideas?
Is it possible to get a Wordpress URL to look like this:
/%post-type%/%custom-taxonomy%/%postname%/
I can get everything but the middle. Any ideas?
You should create custom URLs at the functions.php file, like this:
<?php
function mytheme_flushRoutes()
{
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
function mytheme_queryVars($vars)
{
array_push($vars, 'mycustom');
return $vars;
}
function mytheme_routes($rules)
{
$newrules = array();
$newrules['([^/]+)/([^/]+)$'] = 'index.php?pagename=$matches[2]&mycustom=$matches[1]';
return $newrules + $rules;
}
add_filter('rewrite_rules_array', 'mytheme_routes');
add_filter('query_vars', 'mytheme_queryVars');
add_filter('query_vars', 'mytheme_flushRoutes');
?>
Replace "mycustom" with your own custom taxonomy.
Note that the flushRoutes function may be used only once, then you can remove it from the init filter for a best performance.
After this, you can call it on a wp_query like this:
<?php
global $query_string;
$mycustom = get_query_var('mycustom');
query_posts($query_string.'&posts_per_page=10&orderby=date&meta_key=_mycustom&meta_value='.$mycustom);
?>
Also, you may need to create a filter for generating the permalinks, using the post_link filter.
It's a little complicated, but if you really need to, it's worth it :)
Hope it helps.