Title: URL patterns
Last modified: August 22, 2016

---

# URL patterns

 *  [amillerguy](https://wordpress.org/support/users/amillerguy/)
 * (@amillerguy)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/url-patterns/)
 * Hello,
 * Normally I am a Drupal user, so there might be a simpler solution to this.
 * I want to have custom content types and regular content types that have URL patterns
   like blog/[category]/[title]
 * I tried using a plugin called Auto URL ([https://wordpress.org/support/plugin/auto-url](https://wordpress.org/support/plugin/auto-url))
   but the setup window won’t let me edit any of the URL patterns.
 * What is a work around to create URL patterns for specific content types?
 * Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [janet4now](https://wordpress.org/support/users/janet4now/)
 * (@janet4now)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/url-patterns/#post-5274564)
 * Did you look at the settings > permalink?
 * You can add category or customize there. [http://codex.wordpress.org/Using_Permalinks](http://codex.wordpress.org/Using_Permalinks)
 * Or maybe I don’t understand what you’re trying to do :}
 *  Thread Starter [amillerguy](https://wordpress.org/support/users/amillerguy/)
 * (@amillerguy)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/url-patterns/#post-5274572)
 * 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.
 *  [janet4now](https://wordpress.org/support/users/janet4now/)
 * (@janet4now)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/url-patterns/#post-5274575)
 * Yes, I think that link will answer your questions. It also gives other links 
   for more indepth info and a plugin as well.
 *  Thread Starter [amillerguy](https://wordpress.org/support/users/amillerguy/)
 * (@amillerguy)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/url-patterns/#post-5274843)
 * 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;
       }
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘URL patterns’ is closed to new replies.

## Tags

 * [url](https://wordpress.org/support/topic-tag/url/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [amillerguy](https://wordpress.org/support/users/amillerguy/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/url-patterns/#post-5274843)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
