Skip to:
Content
Pages
Categories
Search
Top
Bottom

I need to shorten the urls of single activity pages.


  • testovac
    Participant

    @testovac

    i Have this link now: https://domain.com/member/johndoe/activity/512/
    but need this: https://domain.com/512/

    how i can do that by some php snippet? pls help

    Something like this? but its bad code i mean

    function custom_activity_link($activity_id = false) {
        global $bp;
        if (!$activity_id) {
            $activity_id = bp_get_activity_id();
        }
        return home_url('/' . $activity_id . '/');
    }
    
    function change_buddypress_activity_permalink() {
        global $bp;
        $bp->activity->root_slug = 'activity';
        add_rewrite_rule('^([0-9]+)/?$', 'index.php?pagename=activity&p=$matches[1]', 'top');
    }
    
    add_action('bp_init', 'change_buddypress_activity_permalink', 2);
    add_filter('bp_get_activity_thread_permalink', 'custom_activity_link', 10, 2);
  • You must be logged in to reply to this topic.
Skip to toolbar