How to add a notice when starting a topic?
-
This is one way…
function ntwb_bbp_theme_before_topic_form_notices() { ?> <div class="bbp-template-notice"> <p>Something here...</p> <p>Something else...</p> </div> <?php } add_action( 'bbp_theme_before_topic_form_notices', 'ntwb_bbp_theme_before_topic_form_notices' );
And another is to modify the
form-topic.php
template.where should I add the code to?
to your functions file see
I put
function ntwb_bbp_theme_before_topic_form_notices() {
?>
<div class=”bbp-template-notice”>
<p>Something here…</p>
<p>Something else…</p>
</div>
<?php}
add_action( ‘bbp_theme_before_topic_form_notices’, ‘ntwb_bbp_theme_before_topic_form_notices’ );but then it says:
Fatal error: Cannot redeclare ntwb_bbp_theme_before_topic_form_notices() (previously declared in /home/gleam/public_html/wp-content/plugins/bbpress/includes/core/functions.php:634) in /home/gleam/public_html/wp-content/plugins/bbpress/includes/core/functions.php on line 628
That’s weird, did you add it twice?
Fatal error: Cannot redeclare ntwb_bbp_theme_before_topic_form_notices() (previously declared..
It could be my hastily quick copy and paste job, here is the same thing with an alternate function name, make sure you remove the previos function. 😉
function ntwb_custom_topic_form_notice() { ?> <div class="bbp-template-notice"> <p>Something here...</p> <p>Something else...</p> </div> <?php } add_action( 'bbp_theme_before_topic_form_notices', 'ntwb_custom_topic_form_notice' );
after putting the new code, it now says:
Fatal error: Cannot redeclare ntwb_custom_topic_form_notice() (previously declared in /home/gleam/public_html/wp-content/plugins/bbpress/includes/core/functions.php:633) in /home/gleam/public_html/wp-content/plugins/bbpress/includes/core/functions.php on line 627
I actually placed the code in bbpress/includes/core/functions.php
is it wrong?Yes, it should NOT go there, you should add it to your child themes
functions.php
file.Remove it from where you added it.
See https://codex.wordpress.org/Child_Themes on creating a child theme.
And this is where you add that code https://codex.wordpress.org/Child_Themes#Using_functions.php
thanks,
I saw the announcement in topic creation.
Can I make the announcement to be shown in topic creation, reply creation and also when editing reply?It’s fixed thanks 🙂
I changed
add_action( ‘bbp_theme_before_topic_form_notices’, ‘ntwb_custom_topic_form_notice’ );into
add_action( ‘bbp_theme_before_topic_form_notices’, ‘ntwb_custom_topic_form_notice’ );
add_action( ‘bbp_theme_before_reply_form_notices’, ‘ntwb_custom_topic_form_notice’ );
- You must be logged in to reply to this topic.