Did you look at the settings > permalink?
You can add category or customize there. http://codex.ww.wp.xz.cn/Using_Permalinks
Or maybe I don’t understand what you’re trying to do :}
Ok what I want is a way that when I have custom content types like:
1. services
2. products
3. portfolio items
That each of these content types can have a separate url pattern based on a predefined pattern that I have selected.
Yes, I think that link will answer your questions. It also gives other links for more indepth info and a plugin as well.
I cannot believe something that is so easy in Drupal is this difficult in the easier CMS.
I am sure perma-links work, if you only have one post type… but if you have more than that you have to get to diving in the code.
I have two content types as of right now, blogs and portfolio items. For blogs I want the url structure to be /blog/%category%/%postname%’. For the portfolio item i want the url structure to be portfolio/%service-tag%/%postname%/
Also for the page post type i just want the url to be /%postname%.
I have tried to code below to get the blog url to work and NOTHING, why is this so difficult?
add_action('init', 'wpq_add_rewrite_rules');
add_filter('post_type_link', 'wpq_permalinks', 10, 3);
function wpq_add_rewrite_rules()
{
// Register custom rewrite rules
global $wp_rewrite;
$wp_rewrite->add_rewrite_tag('%post%', '([^/]+)', 'post=');
$wp_rewrite->add_rewrite_tag('%category%', '([^/]+)', 'category=');
$wp_rewrite->add_permastruct('post', '/blog/%category%/%postname%/', false);
}
function wpq_permalinks($permalink, $post, $leavename)
{
$no_data = 'no-data';
$post_id = $post->ID;
if($post->post_type != 'post' || empty($permalink) || in_array($post->post_status, array('draft', 'pending', 'auto-draft')))
return $permalink;
$data = get_post_meta($post_id, 'permalink_data', true);
if(!$data)
$data = $no_data;
$permalink = str_replace('%category%', sanitize_title($data), $permalink);
return $permalink;
}