[wp-hackers] Another cooky question about permalinks

Mike Schinkel mikeschinkel at gmail.com
Sun Dec 28 21:39:13 GMT 2008


Scribu:

Here is some code that I wrote to reconfigure permalinks for a specific
client's site, maybe you can find something of use in here?  You might want
to conditionally run some of the following code depending on what is the
current URL?


$wp_rewrite->set_permalink_structure(str_replace('/blog/','/',$wp_rewrite->permalink_structure));
    $wp_rewrite->front = '/';

    $wp_rewrite->author_base = 'authors';
    $wp_rewrite->author_structure = '/authors/%author%';

    $wp_rewrite->tag_base = 'tags';
    $wp_rewrite->tag_structure = '/tags/%tag%';

    $wp_rewrite->category_base = 'categories';
    $wp_rewrite->category_structure = '/categories/%category%';

BTW, I've been meaning to post about the patchwork that is WordPress'
permalink handling to see if it could be improved in future versions. As it
is, it is a set of complex rules that are very hard to get right, and AFAIKT
there is no good way to create an override to load a page that isn't like
the rest of the pages that are already baked into the framework.  Would
there be any will on this list to entertain improvement in permalinks?

-Mike Schinkel
http://mikeschinkel.com


On Sun, Dec 28, 2008 at 3:23 PM, scribu <scribu at gmail.com> wrote:

> I'm developing a photoblog using WordPress and I have succesfully changed
> the author base from "author" to something else using this code:
>
> add_action('init', 'replace_author_base');
> function replace_author_base() {
>        global $wp_rewrite;
>
>        $wp_rewrite->author_base = 'photographer';
>        $wp_rewrite->flush_rules();
> }
>
> Having the permalink structure set to "/images/%post_id%", i get this sort
> of URL for author pages:
>
> http://example.com/images/photographer/name
>
> My question is: How could I make the /images/ part apear only for single
> posts and not for category or tag or author pages?
>
>
> --
> http://scribu.net
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list