Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do you do this ?

  • @chouf1

    Participant

    how can i put my modified bp_dtheme_blog_comments function (themes/bp-default/functions.php) in my child theme ‘s function file ?
    i want to modify the comment output.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @boonebgorges

    Keymaster

    bp_dtheme_blog_comments() is a callback for wp_list_comments in comments.php. So the best way is to give your new version a different name (eg chouf_blog_comments() ) and then change comments.php in your new theme to call that function instead of the bp_dtheme version, eg
    ` ‘chouf_blog_comments’ ) ); ?>`

    @chouf1

    Participant

    @Boone Gorges : great, thank you !
    This should be documented somewhere in the BP doc

    i only found this:
    bp_dtheme_blog_comments( $comment, $args, $depth ) X-Ref
    Template for comments and pingbacks.
    To override this walker in a child theme without modifying the comments template
    simply create your own bp_dtheme_blog_comments(), and that function will be used instead.
    Used as a callback by wp_list_comments() for displaying the comments.

    param: mixed $comment Comment record from database
    param: array $args Arguments from wp_list_comments() call
    param: int $depth Comment nesting level

    This tells we can do something not how we can do that. You give the right answer :-)

    @boonebgorges

    Keymaster

    You’re right it could be better commented, but in BP’s defense, this is a core WP functionality, and part of just about every modern theme :) https://codex.wordpress.org/Template_Tags/wp_list_comments

    @boonebgorges

    Keymaster

    Actually, I just looked at the code, and the comment there is correct. The entire function is wrapped in a function_exists check, which means that you could simply put your own version of bp_dtheme_blog_comments() in your child theme’s functions.php, and it would override the one in bp-default (no changes to comments.php necessary). The way that you’ve done it will continue to work just fine, of course.

    @chouf1

    Participant

    @Boone Gorges That is what i done first ! But helas, it doesn’t work: i had a blank page.
    And that is why i asked here…. but if you can give me the command syntax for that function_exists for bp_dtheme_blog_comments (i didn’t find it in WP or BP), i would appreciate ! ;-)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How do you do this ?’ is closed to new replies.
Skip to toolbar