WordPress.org

Ready to get started?Download WordPress

Forums

Year/Issue-based magazine URL structure…how did they do this? (1 post)

  1. lancemonotone
    Member
    Posted 1 year ago #

    I've seen a lot of almost answers but nothing definitive, so here I am.

    I'm trying to structure my WP permalinks as http://magazine.pomona.edu does. The site is organized as http://example.com/%volume_year%/%volume_issue%/%postname%/. Example: http://magazine.pomona.edu/2012/fall/a-carefully-calculated-caper/

    I'm having problems figuring out a permalink structure that doesn't give 404s or 400s. I created two custom taxonomies, 'volume_year' & 'volume_issue'. I changed my permalink structure to reflect these (/%volume_year%/%volume_issue%/%postname%/) and checked the appropriate terms within the post admin (2012 & Fall).

    However, when I attempt to view the post, which should be at http://example.com/2012/fall/lost-and-found/. I get a 400 Bad Request error and my URL is http://example.com/%volume_year%/%volume_issue%/lost-and-found/. Obviously, the placeholders are not being converted to terms. What am I missing, and/or does anyone have a better way to do it?

    Here's my code, fwiw:

    $labels[0] = array(
                'name'                       => 'Year',
                'singular_name'              => 'Year',
                'menu_name'                  => 'Year',
                'all_items'                  => 'All Years',
                'parent_item'                => 'Parent Year',
                'parent_item_colon'          => 'Parent Year:',
                'new_item_name'              => 'New Year Name',
                'add_new_item'               => 'Add New Year',
                'edit_item'                  => 'Edit Year',
                'update_item'                => 'Update Year',
                'separate_items_with_commas' => 'Separate years with commas',
                'search_items'               => 'Search years',
                'add_or_remove_items'        => 'Add or remove years',
                'choose_from_most_used'      => 'Choose from the most used years',
            );
    
            $rewrite[0] = array(
                'slug'                       => 'volume_year',
                'with_front'                 => false,
                'hierarchical'               => true,
            );
    
            $args[0] = array(
                'labels'                     => $labels[0],
                'hierarchical'               => true,
                'public'                     => true,
                'show_ui'                    => true,
                'show_admin_column'          => true,
                'show_in_nav_menus'          => true,
                'show_tagcloud'              => true,
                'query_var'                  => 'volume_year',
                'rewrite'                    => $rewrite[0],
            );
    
            register_taxonomy( 'volume_year', array('post'), $args[0] );
    
            $labels[1] = array(
                'name'                       => 'Issue',
                'singular_name'              => 'Issue',
                'menu_name'                  => 'Issue',
                'all_items'                  => 'All Issues',
                'parent_item'                => 'Parent Issue',
                'parent_item_colon'          => 'Parent Issue:',
                'new_item_name'              => 'New Issue Name',
                'add_new_item'               => 'Add New Issue',
                'edit_item'                  => 'Edit Issue',
                'update_item'                => 'Update Issue',
                'separate_items_with_commas' => 'Separate issues with commas',
                'search_items'               => 'Search issues',
                'add_or_remove_items'        => 'Add or remove issues',
                'choose_from_most_used'      => 'Choose from the most used issues',
            );
    
            $rewrite[1] = array(
                'slug'                       => 'volume_issue',
                'with_front'                 => false,
                'hierarchical'               => true,
            );
    
            $args[1] = array(
                'labels'                     => $labels[1],
                'hierarchical'               => true,
                'public'                     => true,
                'show_ui'                    => true,
                'show_admin_column'          => true,
                'show_in_nav_menus'          => true,
                'show_tagcloud'              => true,
                'query_var'                  => 'volume_issue',
                'rewrite'                    => $rewrite[1],
            );
    
            register_taxonomy( 'volume_issue', array('post'), $args[1] );

Topic Closed

This topic has been closed to new replies.

About this Topic