Custom Post Type “Event” with custom permalink structure

I need some help about Custom permalinks for custom post types.

I have created a custom post type called “evento” and 3 custom fields for storing date, month and year of the events.

Read More

I would like to have a permalinks structure like this:

/eventos/2012/07/30

… where the standard structure would be:

/?post_type=evento&ano=2012&mes=07&dia=30

How to make this magic happen in WordPress? I do not know much about .Htaccess =(

Thanks in advance!!!

Related posts

Leave a Reply

1 comment

  1. Problem solved!!!! =)

    add_action('init', 'evento_add_rewrite_rules');
    function evento_add_rewrite_rules( $wp_rewrite ){
        // Add day archive (and pagination)
        add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/([0-9]{2})/page/?([0-9]{1,})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&dia=$matches[3]&paged=$matches[4]','top');
        add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/([0-9]{2})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&dia=$matches[3]','top');
    
        // Add month archive (and pagination)
        add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/page/?([0-9]{1,})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]&paged=$matches[3]','top');
        add_rewrite_rule("eventos/([0-9]{4})/([0-9]{2})/?",'index.php?post_type=evento&ano=$matches[1]&mes=$matches[2]','top');
    
        // Add year archive (and pagination)
        add_rewrite_rule("eventos/([0-9]{4})/page/?([0-9]{1,})/?",'index.php?post_type=evento&ano=$matches[1]&paged=$matches[2]','top');
        add_rewrite_rule("eventos/([0-9]{4})/?",'index.php?post_type=evento&ano=$matches[1]','top');
    }