Title: Problem with custom permalinks
Last modified: August 20, 2016

---

# Problem with custom permalinks

 *  [olivier89](https://wordpress.org/support/users/olivier89/)
 * (@olivier89)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/problem-with-custom-permalinks-1/)
 * 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%/](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.

## Tags

 * [add_rewrite_rule()](https://wordpress.org/support/topic-tag/add_rewrite_rule/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 0 replies
 * 1 participant
 * Last reply from: [olivier89](https://wordpress.org/support/users/olivier89/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/problem-with-custom-permalinks-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
