Search Results for 'code'
-
AuthorSearch Results
-
March 22, 2023 at 11:35 am #234952
In reply to: SEO friendly theme
Robin W
ModeratorThis code will truncate the title
add_filter ('bbp_new_topic_pre_title' , 'rew_limit_topic_length' ) ; add_filter ('bbp_edit_topic_pre_title' , 'rew_limit_topic_length' ) ; function rew_limit_topic_length ($topic_title) { $length = 40 ; if (strlen($topic_title) > $length) { $topic_title = substr($topic_title, 0, $length); } return $topic_title ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
for your second issue, it is site/theme specific, I’d need to see the site and a real example
March 17, 2023 at 4:14 pm #234901Topic: Blank forum pages – Winkel theme
in forum Troubleshootingwblank83
ParticipantHowdy y’all,
Trying to create a bbpress forum with the Winkel theme
I put the index short code on my page, but when I click through the forum link, I get a blank page
It isn’t plugin related, and I’ve already tried downloading Robin Wilson’s bbp style pack plugin to no avail
Does anyone have some insight into this? I’ve seen it posted several times but just can’t get this to work.
March 14, 2023 at 3:08 pm #234847In reply to: FSE templates and bbPress
rinh
ParticipantThat’s an interesting plugin. But agree gutenberg gets a little convoluted when only used as a text editor.
What I had in mind was being able to add some of the bbPress widgets to the page having the forum root shortcode. These widgets doesn’t seem to appear in gutenberg.
March 14, 2023 at 11:31 am #234845In reply to: FSE templates and bbPress
rinh
ParticipantIt would be good indeed, FSE looks like the future of WordPress.
I just started so I don’t know much, and I think I’ll be in forever learning 😉 I think a template part that is the forum would work best though, but I could be completely wrong on that. I can type down what I’ve got so far though.
From what I’ve gathered so far (I could be wrong on some things here). There are several kinds of templates, for example Archive and Single. Single displays the layout for single posts and that seem to be what all pages except forum root are.
Simply put the templates work in that way you build a layout using the block editor where you can put in single post parts like post title, post content and so on. In Elementor I made a Single with just post content and magically the post content would display the forum on the front-end.
bbPress forum root appear to be an archive, but since it has a shortcode forum root wouldn’t need anything more I think.
The FSE recognise custom post types and you can make Single templates for those. I’m not sure if bbPress is a custom post type, but if it is and FSE would recognise it that would’ve solved it all.
Hope that makes any sense.
March 14, 2023 at 11:10 am #234844In reply to: FSE templates and bbPress
rinh
ParticipantI appreaciate it though 🙂
I realised I have a another problem. Is there any way to get the Recent Topics and Recent Replies widget to work in block editor, or get them to appear some other way for example shortcode? I didn’t realise until now that widgets don’t work in block editor.
Thank you in advance.
March 14, 2023 at 10:47 am #234841In reply to: FSE templates and bbPress
rinh
ParticipantUnfortunately I don’t think any of them is close or can just be cloned.
[bbp-forum-index] – This one works well and can add the forum root anywhere.
But then there’s Forums or Categories, Sub forums and topics/replies themselves. These pages seem to all be seen as ‘posts’ by WordPress, why making a posts template worked in Elementor for all of them. FSE templates seem to ignore bbPress entirely though.
[bbp-single-forum id=$forum_id] – This one do make it possible to add single forums anywhere, but not if they’re inside a forum Category. Would also need one page for each forum which would get a little crazy. I don’t know if this one could be tweaked into something more advanced.
What would be needed is shortcodes for displaying forum Category pages in general, as well as their sub forum pages where the topics are listed. And then all the topic/replies pages too.
All that sound too difficult to be honest.
March 14, 2023 at 9:41 am #234837In reply to: FSE templates and bbPress
Robin W
Moderatorpresume you are familiar with all these
March 14, 2023 at 9:35 am #234836In reply to: FSE templates and bbPress
rinh
ParticipantOh yes, I use the plugin to be able to display the forum in block themes. Thank you for the plugin by the way and all the work you do on them and this forum 🙂
This is more about I’d like to put the forum in templates to be able to put additional content, for example I put a welcome message/info as well as a custom made sidebar in the Elementor template.
I suppose there’s no shortcodes for displaying forums (other than root) as well as one for all topics? 😛
I can totally understand avoiding getting too deep into FSE. I really appreciate it too, it’s like a mini theme builder. The learning curve do feels steep though.
March 14, 2023 at 9:19 am #234835In reply to: FSE templates and bbPress
Robin W
Moderatormy style pack has some code that fixes (sort of) FSE themes
install
once activated, navigate to
dashboard>settings>bbp style pack, and you should see the first tab called ‘Theme Support’ – if you don’t see this, come back.
In that tab, select
Enable Theme Support
and save
The forums should then display
If you want to look at code, then download the plugin to your computer and find
\bbp-style-pack\trunk\includes\functions_theme_support.php
I’m trying to avoid getting too deeply into FSE – I find it annoying, but appreciate that I am old and ludite, and that many find it fine or even great 🙂
March 14, 2023 at 8:53 am #234834Topic: FSE templates and bbPress
in forum Themesrinh
ParticipantHi
I’m looking into the possibility to move a community site from using Elementor Pro to WordPress own Full Site Editing and block theme.I’m curious if anyone has figured out how to apply templates to the forums and topics themselves. The forum root works fine though because it has a shortcode.
In Elementor I worked it out by making a single post template and then exclude posts and custom post types from it, but in FSE it doesn’t seem possible to apply any templates to bbPress at all.
Thank you in advance
March 14, 2023 at 4:20 am #234816In reply to: bbpress showing blank pages and duplicated fields
Robin W
ModeratorI spent a couple of hours yesterday hunting down the issue.
This code fixes it :
add_filter ('astra_single_layout_one_banner_visibility', 'astra_bbpress_fix', 50) ; function astra_bbpress_fix ($value) { if( class_exists( 'bbpress' ) ) { if (bbp_is_single_user()) return false ; if (bbp_is_search()) return false ; } return $value ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
March 14, 2023 at 4:19 am #234815In reply to: “User” Page seems to be stuck in a loop
Robin W
ModeratorI spent a couple of hours yesterday hunting down the issue.
This code fixes it :
add_filter ('astra_single_layout_one_banner_visibility', 'astra_bbpress_fix', 50) ; function astra_bbpress_fix ($value) { if( class_exists( 'bbpress' ) ) { if (bbp_is_single_user()) return false ; if (bbp_is_search()) return false ; } return $value ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
March 14, 2023 at 4:18 am #234814In reply to: Search goes to infinite loop with Astra theme.
Robin W
ModeratorI spent a couple of hours yesterday hunting down the issue.
This code fixes it :
add_filter ('astra_single_layout_one_banner_visibility', 'astra_bbpress_fix', 50) ; function astra_bbpress_fix ($value) { if( class_exists( 'bbpress' ) ) { if (bbp_is_single_user()) return false ; if (bbp_is_search()) return false ; } return $value ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
March 13, 2023 at 2:28 pm #234811In reply to: remove email + website field
Robin W
ModeratorApologies for the delay is responding to this.
Assuming you are ok with FTP, then
find
wp-content/plugins/bbpress/templates/default/bbpress/form-anonymous.phptransfer this to your pc and edit to remove
<p> <label for="bbp_anonymous_email"><?php esc_html_e( 'Mail (will not be published) (required):', 'bbpress' ); ?></label><br /> <input type="text" id="bbp_anonymous_email" value="<?php bbp_author_email(); ?>" size="40" maxlength="100" name="bbp_anonymous_email" /> </p> <p> <label for="bbp_anonymous_website"><?php esc_html_e( 'Website:', 'bbpress' ); ?></label><br /> <input type="text" id="bbp_anonymous_website" value="<?php bbp_author_url(); ?>" size="40" maxlength="200" name="bbp_anonymous_website" /> </p>
and save
create a directory on your theme called ‘bbpress’
ie wp-content/themes/%your-theme-name%/bbpresswhere %your-theme-name% is the name of your theme
Then transfer the file you saved above and put in in the directory called bbpress that you created above, so you end up with
wp-content/themes/%your-theme-name%/bbpress/form-anonymous.phpbbPress will now use this template instead of the original
Alternately if this all confuses you, I can do this as a plugin, but it would be a paid bit of work (but not expensive) – contact me via http://www.rewweb.co.uk/contact-me/
March 13, 2023 at 8:13 am #234793In reply to: Change Title of Forum Index page?
valarcher
ParticipantHi Robin – do you perhaps have any solution to that code? I’m trying to grey out the user’s email on their profile page so they can see it but not be able to update it (same as username). But I need users to update other info like website and bio. That code above does not allow *any* edits to profile page. So my users are unable to write anything into their bio if I use that code.
March 13, 2023 at 5:13 am #234784In reply to: Change Title of Forum Index page?
valarcher
ParticipantHi Robin – thanks million for renaming title. That php works perfectly. Sadly the other problem of 1/3-col doesn’t work addressing #bbpress-forums. It works if I target the entire page, then every forum title like this:
#post-9486,#bbp-forum-9475,#bbp-forum-9473,etc {width:100%;}
but the moderator doesn’t have access to css so won’t be able to add every forum to css when she creates it.I’ll carry on hounding astra for solution. Otherwise worst case scenario I just set blog archives to 1 column.
While I have you… your code here:
/** bbPress: add description under forum titles
https://codex.bbpress.org/layout-and-functionality-examples-you-can-use/ */function rw_singleforum_description() { echo '<div class="bbp-forumpage-content">'; echo bbp_forum_content(); echo '</div>'; } add_action( 'bbp_template_before_single_forum' , 'rw_singleforum_description');
You have the first echo as “bbp-forum-content” but by changing it to “forumpage-content”, we’re able to target the description on index page and description on forum page separately in css, eg. on forum pages I have it red bold and centered, whereas on index page I have it in regular left-aligned text.
Thanks million for all the work you put into the codex! I’m not keen on installing plugins such as your style pack, so codex is really helpful finding just the php I need.
Do you perhaps have any solution to this code? I’m trying to grey out the user’s email on their profile page so they can’t update it. But I need users to update other info like website and bio. However with code below, if I test writing words in bio (as a logged in participator, not as keymaster) and try saving it, I get “Error: Please enter an email address.” I can see the email greyed out there.
Do you know a way to fix it so ONLY the email and role can NOT be changed (although role does not even display on a participant user’s page) and everything else can be edited? (except for username of course)
/** bbPress/WP: prevents subscriber from changing email (greyed out)
https://www.role-editor.com/hide-disable-wordpress-user-profile-fields/ */add_action('admin_init', 'user_profile_fields_disable'); function user_profile_fields_disable() { global $pagenow; // apply only to user profile or user edit pages if ($pagenow!=='profile.php' && $pagenow!=='user-edit.php') { return; } // do not change anything for the administrator if (current_user_can('administrator')) { return; } add_action( 'admin_footer', 'user_profile_fields_disable_js' ); } /** * Disables selected fields in WP Admin user profile (profile.php, user-edit.php) */ function user_profile_fields_disable_js() { ?> <script> jQuery(document).ready( function($) { var fields_to_disable = ['email', 'role']; for(i=0; i<fields_to_disable.length; i++) { if ( $('#'+ fields_to_disable[i]).length ) { $('#'+ fields_to_disable[i]).attr("disabled", "disabled"); } } }); </script> <?php }
I know nothing about php – other than simple stuff like seeing I can change forum-content to forumpage-content!
March 12, 2023 at 1:28 pm #234759In reply to: Change Title of Forum Index page?
Robin W
Moderatorso for your first, try this
add_filter( 'get_the_archive_title', 'rew_amend_forums' , 10 , 3) ; function rew_amend_forums ($title, $original_title, $prefix ) { if ($title == 'Forums') $title = 'Private Forums' ; return $title ; }
for your second, this is really one for Astra – I could spend many hours looking for an answer is their code.
but based on your previous post you could try
#bbpress-forums {width:100%;}
March 11, 2023 at 11:41 am #234742Topic: Change Title of Forum Index page?
in forum Installationvalarcher
ParticipantHi – I’m trying to change the title of my forum index page. I tried item 3 method 2 at:
— saving my index page as /members (not /forums) as per WP settings, and then tried to give members page in wordpress the title “Private Forums” (instead of title Members). It displays as “Private Forums” (not “Members”) in the breadcrumb. But still on main index page, it displays only the title “Forums.”I’m using the shortcode [bbp-forum-index] on /members page as I have text above and below it.
What can I add to functions.php that will force that index page to display the title “Private Forums”?
Thank you!
March 11, 2023 at 9:35 am #234740In reply to: Blank topic pages while using TwentyTwentyTwo theme.
Sergio De Falco
ParticipantMy step up, also install/update Gutenberg standalone plugin to the latest version and add this to your own plugin / theme functions.php
function envireit_bbp_register_forum_post_type( $args ) { $args['show_in_rest'] = true; return $args; } add_filter( 'bbp_register_forum_post_type', 'envireit_bbp_register_forum_post_type' ); function envireit_bbp_register_topic_post_type( $args ) { $args['show_in_rest'] = true; return $args; } add_filter( 'bbp_register_topic_post_type', 'envireit_bbp_register_topic_post_type' ); function envireit_bbp_register_reply_post_type( $args ) { $args['show_in_rest'] = true; return $args; } add_filter( 'bbp_register_reply_post_type', 'envireit_bbp_register_reply_post_type' );
With this you will be able to build via site builder, your own forums, topics and replies page. Just replace the content loop with the article content block.
March 10, 2023 at 1:52 pm #234731In reply to: Style pack breaking theme
3dbyte
ParticipantI tested your codes working without problem. By the way I didn’t use header color. Just footer enough because inside “forum index styling” changing already.
Sincerely thanks Robin, have a good day.March 10, 2023 at 1:35 pm #234730In reply to: Style pack breaking theme
Robin W
Moderatorwaiting for an email from someone else, so playing with this – this should work
#bbpress-forums li.bbp-header { background-color: blue; } #bbpress-forums li.bbp-footer { background-color: green; }
if you put this in
dashboard>settings>bbp style pack>custom css
then it will exceute at the right point
let me know if it doesn’t work
March 10, 2023 at 12:54 pm #234727In reply to: blacklist_keys in bbpress functions.php
Robin W
ModeratorIn suspect if you are posting as you (eg say a keymaster) then it won’t do the check, can’t say for sure without delving into code, but try as a participant
March 10, 2023 at 11:21 am #234722In reply to: blacklist_keys in bbpress functions.php
Mike Witt
ParticipantThat’s what I was planning to do, but I can’t replicate the problem. When I just make a couple of posts and replies, I don’t get the php notice. That’s why I was thinking maybe it wasn’t bbPress. There must be something special I need to do, to invoke the “blacklist” thing? It happens every once in a while. But I can’t find an action that causes it to happen. I gather that you don’t see it happening, right?
[10-Mar-2023 04:55:26 UTC] PHP Deprecated: Function get_option was called with an argument that is <strong>deprecated</strong> since version 5.5.0! The "blacklist_keys" option key has been renamed to "disallowed_keys". in .../public_html/wp-includes/functions.php on line 5667
March 10, 2023 at 7:55 am #234716In reply to: Forum Issues
Robin W
ModeratorMarch 10, 2023 at 7:50 am #234713In reply to: Different Replies per Page for Mobile Theme
Robin W
Moderatorso try this code, amending the numbers to what you want
if (wp_is_mobile()) { add_filter ('bbp_get_topics_per_page', 'mobile_topics_per_page') ; add_filter ('bbp_get_replies_per_page', 'mobile_replies_per_page') ; } function mobile_topics_per_page () { return '4' ; } function mobile_replies_per_page () { return '3' ; }
Put this in your child theme’s function file –
ie wp-content/themes/%your-theme-name%/functions.php
where %your-theme-name% is the name of your theme
or use
-
AuthorSearch Results