Skip to:
Content
Pages
Categories
Search
Top
Bottom

Topic ID instead of slugs?

  • @korobochkin

    Participant

    bbPress permalinks by default is:

    • /forums/topic/TOPIC_SLUG/
    • /forums/forum/FORUM_SLUG/

    How to replace topic- and forum- slugs to their ID’s?

    • /forums/topic/TOPIC_ID/
    • /forums/forum/FORUM_ID/

    I need this because I have cyrillic letters in topic names (and slugs).

    Current link:

    http://ru.forums.wordpress.org/topic/Пустая-страница-1?replies=3

    After copy and send on Twitter, Facebook..:

    http://ru.forums.wordpress.org/topic/

    I try fix it and write rewrite rule (and flush, yep).

    add_rewrite_rule('^/forum/topic/(\d+)/?$','index.php?topic_id=$matches[1]','top');

    But after visiting /forum/topic/814 (814 topic id is exists) redirect to home page happening.

Viewing 7 replies - 26 through 32 (of 32 total)
  • @korobochkin

    Participant

    Finally! I find the solution for this issue. flush_rewrite_rules () doesn’t work if you don’t add rules before call it. So we need add our rules on plugin activation and only after this call flush_rewrite_rules (). I call this function and pass false arg because we need soft flush, without .htaccess rewriting.

    Github repo already updated.


    @pooledge
    your forum http://pupyshevo.hol.es/forums/forum/9/ work perfectly with digit in links right now.

    @korobochkin

    Participant

    I think that add_action (‘init’, ‘bbp_permalinks_init’, 0); is bad. I attach my function with add rewrite rules on bbp_init hook.

    Need to check when you call bbp_init hook.

    @pooledge

    Participant

    Dear Kolya, your fix works like a charm. Still there is a plugin unrelated bug while using cyrillic forum prefixes, but hey with you plugin working I can live with that until it’s being fixed.

    Thank you very much for the excellent support,
    Oleg

    @korobochkin

    Participant

    This happens when you change bbPress settings. For example forum slug or topic slug. Right now this can be fixed by flushing rewrite rules manually. My plugin don’t add any rules and hooks on this event. I keep digging into bbPress.

    @netweb

    Keymaster

    @korobochkin

    Participant

    @pooledge just update my super-duper plugin 🙂 now it works fine with all permalink setups. Checkout and update — https://github.com/korobochkin/bbPress-permalinks-with-id

    Known issue
    If permalink looks like site.com?p=123 (not pretty permalink), the topic and reply edit links looks like:

    site.com/?post_type=topic&p=814&topic=TOPIC_SLUG&edit=1
    // TOPIC_SLUG — I dont known right now how to delete it but works fine with this parameter.

    @korobochkin

    Participant

    The plugin comes to wordpress org! Checkout https://wordpress.org/plugins/bbpress-permalinks-with-id/

    Right now without auto flushing rules 😭

Viewing 7 replies - 26 through 32 (of 32 total)
  • You must be logged in to reply to this topic.
Skip to toolbar