Site icon Hip-Hop Website Design and Development

Rewrite Rule & Regex – Extract ‘cat-name’ and ‘page-number’ from http://area.com/custom-post-type/class/cat-name/web page/page-number

I’ve an URL formatted so:

http://area.com/custom-post-type/class/cat-name/web page/page-number

I must extract:

cat-name and page-number

In order that in my capabilities.php, I can create the {custom} rewrite rule:

operate my_insert_rewrite_rules( $guidelines ) {
  $newrules = array();
  $newrules['projects/category/(.+)/page/(d+)/?$'] = 'index.php?post_type=undertaking&project_cat=$matches[1]&paged=$matches[2]';
  return $newrules + $guidelines;
}

I’m making an attempt to make use of the expression:

initiatives/class/(.+)/web page/(d+)/?$

Which appears to work appropriately (escaping the ahead slashes) on this instance: http://rubular.com/r/5rzECsTexy

Nevertheless, this by no means appears to work, the URL:

http://area.com/initiatives/class/print and http://area.com/initiatives/class/print/web page/2 all the time appear to 404.

My earlier rewrite rule of initiatives/class/(.*/?)$ labored for the class, however didn’t pull the web page quantity correctly.

Edit
Customized Put up Kind license plate (in my theme’s operate.php)

// Customized Put up Varieties
add_action( 'init', 'create_post_type' );
operate create_post_type() {
    register_post_type( 'undertaking',
        array(
            'labels' => array(
                'identify' => __( 'Initiatives' ),
                'singular_name' => __( 'Challenge' )
            ),
        'public' => true,
        'has_archive' => true,
        'taxonomies' => array('class'),
        'rewrite' => array('slug' => 'initiatives')
        )
    );
}