Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide/Edit Forum from Breadcrumb


  • mibrenner
    Participant

    @mibrenner

    Hi –

    Rather than using the default ‘forum’ page to display my forum, I am embedding the forum on a custom static page using a shortcode.

    I’d like to update the breadcrumbs and either hide (preferred) the default forum name/URL, or, edit the forum URL. I doubt I can edit the URL, so I’m okay with hiding the URL and manually injecting the URL in my functions.php file using the arg [‘before’]. Unfortunately, I don’t see a way to hide the specific Forum from the breadcrumbs. See possible arguments here: https://github.com/ntwb/bbPress/blob/master/src/includes/common/template.php#L2277-L2303

    Out of the box:
    Home (/) » Forums (/forums) » Forum Title (/forums/forum/forum-title/) » Topic

    Ideal:
    Forum Title (/custom-page/) » Topic

    Actual (based on code below):
    Forum Title (/custom-page/) » Forum Title (/forums/forum/forum-title/) » Topic

    Here is the code I’m using to make that happen. Looking for a way to hide that second Forum Title.

    function custom_bbp_breadcrumb() {
        $args['before'] ='<div class="bbp-breadcrumb"><p><a href="/custom-page/" class="bbp-breadcrumb-forum">Forum Title</a><span class="bbp-breadcrumb-sep"> &raquo; </span>';
        $args['include_home'] = false;
        $args['include_root'] = false;
        return $args;
    }
    
    add_filter('bbp_before_get_breadcrumb_parse_args', 'custom_bbp_breadcrumb' );
Viewing 5 replies - 1 through 5 (of 5 total)

  • Robin W
    Moderator

    @robin-w

    this plugin lets you do that (if I understand your question)

    bbp style pack

    once activated go to

    dashboard>settings>bbp style pack>Breadcrumbs

    if you want to do it programmatically your self look at the plugins functions file

    includes/functions.php

    around line 607 onwards


    mibrenner
    Participant

    @mibrenner

    Thanks for your reply, Robin. I activated your plugin and looked through your functions file but, unfortunately, neither route addresses my issue, which is editing the specific forum’s URL.

    Even in one of your plugin’s screenshots, you don’t show the specific forum as editable within the breadcrumbs. “Main Forum”, between Root and Current.

    breadcrumb settings


    Robin W
    Moderator

    @robin-w

    the original function is in

    bbpress/includes/common/template.php and starts on line 2227

    line 2419 creates the breadcrumb and to hide you would hide class bbp-breadcrumb-forum

    line 2478 is the best place to change what you want, you would use that filter and cycle though the breadcrumb array and amend or take out the forum one.

    Sorry beyond my time availability to code this for you.


    mibrenner
    Participant

    @mibrenner

    Thank you for your help. That helped me filter through the different parts of the breadcrumb and selectively replace the default forum URL with my static forum URL.

    For anyone else reading this that wants the code I used, to replace the URL (or text if you want to) of the “Forum” portion of the breadcrumb:

    function gnpwdr_bbp_breadcrumb_url($crumbs) {
      global $bsp_breadcrumb;
      $pattern = '/(?<=href\=")[^]]+?(?=")/';
      $my_forum_url = '/custom-page/';
      $crumbs[0] = preg_replace($pattern, $my_forum_url, $crumbs[0]);
      return $crumbs; 
    }
    add_filter('bbp_breadcrumbs', 'gnpwdr_bbp_breadcrumb_url');

    Robin W
    Moderator

    @robin-w

    great – glad you are fixed, and thanks for posting back the result

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