0

I'm new to PHP and trying to learn my way through Wordpress. Within my theme's functions.php file, I wanted to access a method available inside bbPress's plugin template.php file. I'm getting "Unexpected token ['

Inside bbPress plugin template.php:

function bbp_topic_reply_count( $topic_id = 0, $integer = false ) {
    echo bbp_get_topic_reply_count( $topic_id, $integer );
}

I'm accessing this function in my current theme's functions.php:

$count = bbp_topic_reply_count(125);

Do I have to include anything from the plugin (i.e bbpress/template.php)?

Thanks.

1 Answer 1

0

Normally not (it depends on what part of the plugins code you want to use and how the plugin initializes itself in the context in which you want to do it), the main plugin files are loaded as part of the wordpress boot process and the convention is that they will load the other files in the plugin at that time, therefor all the function declared in a plugin should be available to use after the boot was finished, and especially in a theme.

The error you are getting is probably just a syntax error in your code.

1
  • Thanks, the error was because bbp_topic_reply_count() returns an 'echo' output which my caller wasn't handling.
    – Loc Pham
    Commented Oct 6, 2015 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.