Site icon Hip-Hop Website Design and Development

Passing variables within the permalink construction on a customized publish kind

I’ve a construction like this for my customized publish varieties:

area.com/member/member-name/e-book/book-name

Mainly, I’ve a customized publish kind of member, and the member-name is the publish. What I wish to do is move a variable referred to as books, however I am unable to get my code to work.

I’ve primarily based my answer on one which has beforehand been requested on right here however my construction is totally different, and I’ve googled and googled to no avail. I actually cant get my head round rewrite buildings both!

    perform add_book_rewrite() {
        add_rewrite_tag('%book_name%','([^&]+)');
    }
    add_action( 'init', 'add_book_rewrite' );

    perform add_book_rewrite_rules() {
        add_rewrite_rule('^member/([^/]*)/e-book/([^/]*)/?','index.php?post_type=member&title=$matches[2]&book_name=$matches[4]','high');
    }
    add_action( 'init', 'add_book_rewrite_rules' );

    add_filter( 'query_vars', 'add_query_var' );

    perform add_query_var( $query_vars ) {

        $query_vars[] = 'book_name';
        return $query_vars;
    }

    echo 'Ebook is '.get_query_var('book_name');

Any tips on this may be obtained with gratitude

Thanks