• Resolved bcyork

    (@bcyork)


    I amy trying to put posts under .com/contributor/name/posttitle

    I’m using this in functions.php to rewrite the author slug so its .com/contributor/name/.

    add_action('init', 'cng_author_base');
    function cng_author_base() {
        global $wp_rewrite;
        $author_slug = 'contributor';
        $wp_rewrite->author_base = $author_slug;
    }

    However because i have this

    /contributor/%author%/%postname%/

    in the permalink settings I get the below as links to the author page.

    .com/contributor/contributor/name/

    Any idea how to make this happen via code or default wordpress settings?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try adding $wp_rewrite->front = ''; as well, and flush your rewrite rules (just visit the permalinks page).

    Note: this will also remove the ‘contributor/’ base from other non-post pages, such as category archives.

    Thread Starter bcyork

    (@bcyork)

    Thank you so much Kailey! That works by putting that at the bottom like below and leaving the permalink settings the way i had in the original post.

    // Change Author URL slug to contributor
    add_action('init', 'cng_author_base');
    function cng_author_base() {
    
        global $wp_rewrite;
        $author_slug = 'contributor'; // change slug name
        $wp_rewrite->author_base = $author_slug;
    	$wp_rewrite->front = '';
    }
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Permalink for posts under author’ is closed to new replies.