I’ve read some posts and it looks that lots of people want to play with their permalinks. WP handles great this link customization but I was unable to find anything for bbPress. Does anyone had any success with changing the mod_rewrite rules and modifying the current permalinks?
Thanx.
I don’t know anyone that has successfully done it (at least I can’t remember a post or anyone bragging about it), but I created a TRAC ticket for a future version on this issue:
https://trac.bbpress.org/ticket/579
You might be able to play with rewrite-rules.php in the /bb-admin/ folder to get some direction on what to change in the meantime to play with it, but I don’t believe it is pluggable (for a plugin).
Trent
All the magic happens in bb_repermalink() in bb-includes/function.php but the real problem here is that get_path() splits by “/” to find out the topic/forum/user id.
You could plugin to bb_repermalink() and change the value of $permalink that way.
e.g. if your permalinks were of the form, forum-12, topic-34 etc. (already setup in your .htaccess file)
You could make the following file…
function my_pre_permalink() {
$p = get_path(0);
$p = split('-', $p);
$p = $p[1];
return $p;
}
add_action('pre_permalink', 'my_pre_premalink');
Drop that into your plugins directory and it should work.
Of course I haven’t tested this, but it should work in theory.
Actually, it’s harder than this. What I wrote above is only a part of the issue. I’m working on a patch at the moment.
Here’s a sneak peak at the patch functionality….
http://www.network.net.au/bbpress/patches/permalinks/teaser.gif
Still working out a few details.
Open bb-includes/template-functions.php and change:
$link = bb_get_option(‘uri’) . “forum/$forum->forum_id” . ( 1 < $page ? “/page/$page” : ” );
to
$link = bb_get_option(‘uri’) . “forum-$forum->forum_id” . ( 1 < $page ? “/page/$page” : ” );
Now open your .htaccess file and change:
RewriteRule ^forum/(.+)/page/?([0-9]{1,})/?$ forum.php?id=$1&page=$2 [QSA,L]
RewriteRule ^forum/(.+)/?$ forum.php?id=$1 [QSA,L]
to
RewriteRule ^forum-(.+)/page/?([0-9]{1,})/?$ forum.php?id=$1&page=$2 [QSA,L]
RewriteRule ^forum-(.+)/?$ forum.php?id=$1 [QSA,L]
bye
I’ve made something similar. It still needs some work. You can see the result at http://www.dfur.com and download the plugin from https://bbpress.org/forums/topic/771
This is my first plugin wrote and it needs some more work with the .htaccess rules. The pagination is not yet fixed and if somone could help me please let me know.
Thanx.