Support » Everything else WordPress » Problem with custom permalinks

  • olivier89

    (@olivier89)


    I didn’t manage to get satisfactory breadcrumb with the plugin avalaible, so i had to add a query var (parentid) to create my breadcrumb and have a proper menu action.
    For my theme i created custom post types (realisation, video).

    All is working now but i have trouble when i setup rewriting.

    my urls are like this :
    1) ?realisation=habillage-de-stands&parentid=38 // for custom post type ‘realisation’
    2) ?video=jardin-d-ailleurs&parentid=visite-jardin // for custom post type ‘video’
    3) ?video_category=institutionnel&parentid=pedagogique //for custom tag ‘video_category’ associated to custom post type ‘video’
    4) ?p=31&parentid=34 //for blog article
    5) ?tag=site-web&parentid=34 //for tags

    I tried in permalink

    http://127.0.0.1/CONSTRUCTION/wordpress/%postname%/
    mais then, les url ne fonctionnent pas (404)

    So i added in functions.php

    function add_parentid_rewrite()
    {
        add_rewrite_rule('^realisation/([^/]*)/([^/]*)', 'index.php?realisation=$matches[1]&parentid=$matches[2]', 'top');
        add_rewrite_rule('^video/([^/]*)/([^/]*)', 'index.php?video=$matches[1]&parentid=$matches[2]', 'top');
    	add_rewrite_rule('^video_category/([^/]*)/([^/]*)', 'index.php?video_category=$matches[1]&parentid=$matches[2]', 'top');
    }
    add_action( 'init', 'add_parentid_rewrite' );

    and i have
    ?realisation=habillage-de-stands&parentid=38
    becomes
    realisation/habillage-de-stands/&parentid=0/
    the link is working but i wish to have
    realisation/habillage-de-stands/38/

    also
    ?video=jardin-d-ailleurs&parentid=visite-jardin
    becomes
    video/jardin-d-ailleurs/&parentid=visite-jardin/

    and also
    ?video_category=institutionnel&parentid=pedagogique
    becomes
    video_category/institutionnel/&parentid=&parentid=pedagogique //width 2 &parentid= !!
    but the link is working
    => what is wrong ? why &parentid= stays in the rewrite link ?

    But
    ?p=31&parentid=34
    becomes
    article2/&parentid=0
    and doesn’t work

    => What could be done here for this ?

    Thanks

  • The topic ‘Problem with custom permalinks’ is closed to new replies.