• hi,
    i introduced a new post type with ‘custom post types ui’ and used ‘custom post types permalinks’ Tod set the entry links to /events/%year%/%monthnum%/%postname%.
    This is working fine so far.
    If i browse to /events/2013/10 all events planned for october 2013 are listed.
    But if i browse to /events/2013/ all non custom post published in 2013 are listed.
    It seems that the post_type gets lost for wp_query.

    i tried registering a rewrite rule like (‘events/([0-9]{4})/?$’,’index.php?post_type=events&year=$matches[1]’). but this doesn’t help.

    any proposals?

    regards,
    Robert

Viewing 2 replies - 1 through 2 (of 2 total)
  • Did you re-save your already in use permalink setting(s) after creating the new post type?

    Oh, and is there a closing / at the end of your custom permalink setting?

    Does the query output change if the year does not have the last / ??

    Thread Starter rs200

    (@rs200)

    yes I re-saved the permalink settings. I also activated the $wp_rewrite->flush_rules(); within my rewrite function. After I’ve done this, /events/2013/10 and /events/2013/ works but I got a 404 for /events/2013/10/entry1. When I re-saved the permalink settings, where the ‘custom post types permalinks’ plugin allows me to set the permalink for events to events/%year%/%monthnum%/%postname%/, the entry the monthly list is working but not for the year.

    function my_rewrite() {
        global $wp_rewrite;
    	// $wp_rewrite->add_permastruct('events', '/events/%year%/%monthnum%/%postname%/', False, 1);
    	add_rewrite_rule('events/([0-9]{4})/?$', 'index.php?post_type=events&year=$matches[1]', 'top');
        add_rewrite_rule('events/([0-9]{4})/([0-9]{2})/?$', 'index.php?post_type=events&year=$matches[1]&monthnum=$matches[2]', 'top');
    
        // $wp_rewrite->flush_rules(); // !!!
    }

    maybe I should disable the plugin and set all permalinks and rewrites manually?

    And yes there is a closing / at the end. But it doesn’t matter if I browse with or without /.

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

The topic ‘custom post type lost on permalink’ is closed to new replies.