• Hi, i’m trying to build my own classified ads plugin.
    But i’m stuck with the rewriting rules.

    1) First; are they fully finished in the beta or will it evolve ?
    e.g. there is no “home” actually for the custom post type.
    /wordpress/classifieds-ads brings a 404.

    2) Will there be rules added automatically for custom taxonomies or have I to create them myself ?

    I have 3 custom taxonomies;
    yclad_action (eg. classifieds/type/OFFERS or classifieds/type/PROPOSALS)
    yclad_tags (used like post tags)
    yclad_category (used like post categories)

    3) Is it possible to build new rules on “top” of existing rules or have I to create them all from scratches ?

    Well, what I would like is to have rewriting just as post does.

    So for example; I would like to be able to have urls like

    /classified-ads/type/offers (where “offers” is a yclad_action)
    /classified-ads/type/proposals/category/cars (where “proposals” is an yclad_action and “cat-1” is a yclad_category)
    /classified-ads/type/proposals/category/cars/tag/red (where “red” is a yclad_tag)

    and combine them with regular rules (author,time args,etc.).

    Eg for a complex one :

    /classified-ads/2009/12/type/proposals/category/cars/tag/red

    would load
    -that custom post type
    -from december 2009
    -where the yclad_action is “proposals”
    -in the yclad_category “cars”
    -with the yclad_tag “red”.

    I’ve used a plugin called “AskApache RewriteRules Viewer” that lists the rules that WP seems to create automatically for custom post types.
    Currently, It shows

    Array
    (
        [extra_rules_top] => Array
    (
        [classified-ads/[^/]+/attachment/([^/]+)/?$] => index.php?attachment=$matches[1]
        [classified-ads/[^/]+/attachment/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
        [classified-ads/[^/]+/attachment/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
        [classified-ads/[^/]+/attachment/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
        [classified-ads/[^/]+/attachment/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
        [classified-ads/([^/]+)/trackback/?$] => index.php?yclad=$matches[1]&tb=1
        [classified-ads/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?yclad=$matches[1]&feed=$matches[2]
        [classified-ads/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?yclad=$matches[1]&feed=$matches[2]
        [classified-ads/([^/]+)/page/?([0-9]{1,})/?$] => index.php?yclad=$matches[1]&paged=$matches[2]
        [classified-ads/([^/]+)(/[0-9]+)?/?$] => index.php?yclad=$matches[1]&page=$matches[2]
        [classified-ads/[^/]+/([^/]+)/?$] => index.php?attachment=$matches[1]
        [classified-ads/[^/]+/([^/]+)/trackback/?$] => index.php?attachment=$matches[1]&tb=1
        [classified-ads/[^/]+/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
        [classified-ads/[^/]+/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?attachment=$matches[1]&feed=$matches[2]
        [classified-ads/[^/]+/([^/]+)/comment-page-([0-9]{1,})/?$] => index.php?attachment=$matches[1]&cpage=$matches[2]
    )

    But for example, I guess

    [classified-ads/([^/]+)/page/?([0-9]{1,})/?$] => index.php?yclad=$matches[1]&paged=$matches[2]

    is used to use pagination (eg. classifieds-ads/page/2), but currently it does not work. (404 not found)
    Also, is this regex, what does ([^/]+) means ?

    Thanks A LOT.

  • The topic ‘Rewriting custom post types ?’ is closed to new replies.