- This topic has 9 replies, 2 voices, and was last updated 2 years, 11 months ago by
David.
-
AuthorPosts
-
March 25, 2023 at 4:39 pm #2582097
Riccardo
Hey guys, I hope you are doing well. I’ve successfully set my BBpress forum using your CSS and I’m very satisfied by the look and feel. There’s a small issue that you may be able to fix. I have set up a custom header with a search bar, which looks ok on the screen but it’s ridiculously small on mobile. Also, I would like to add “search keyword…” as a placeholder in the search bar instead of adding a title above. Can you please help to fix it? thanks a lot!
March 26, 2023 at 5:00 am #2582490David
StaffCustomer SupportHi there,
use this CSS to set a max-width of the search for desktop and for it to fill the width on mobile:
#bbp-search-form input[type="text"] { width: 100% !important; max-width: 640px; }I am not sure for the placeholder text, but you can try adding this PHP Snippet:
function custom_bbpress_search_placeholder( $placeholder ) { $placeholder = 'Search keyword...'; return $placeholder; } add_filter( 'bbp_get_search_input_placeholder', 'custom_bbpress_search_placeholder' );March 26, 2023 at 5:15 am #2582508Riccardo
Thank you very much, David. The mobile bar looks fine now, the placeholder doesn’t show.
March 26, 2023 at 8:33 am #2582897David
StaffCustomer SupportHow is the search form added to the site ?
March 26, 2023 at 11:35 pm #2583515Riccardo
Element Header, bb search shortcode very simple. Attached. Thank you!
March 27, 2023 at 6:06 am #2583951David
StaffCustomer SupportOK, so looking at the BBPress github – they use this template for that search form:
https://github.com/bbpress/bbPress/blob/trunk/src/templates/default/bbpress/form-search.php
And it has no placeholder or any filters to change that.
So you could create your own search form Shortcode with this PHP Snippet:
add_shortcode( 'my_bb_search', function() { if ( !bbp_allow_search() ) { return; } $html = sprintf( '<div class="bbp-search-form"> <form role="search" method="get" id="bbp-search-form"> <div> <label class="screen-reader-text hidden" for="bbp_search">%1$s</label> <input type="hidden" name="action" value="bbp-search-request" /> <input placeholder="Enter your search" type="text" value="%2$s" name="bbp_search" id="bbp_search" /> <input class="button" type="submit" id="bbp_search_submit" value="%3$s" /> </div> </form> </div>', esc_html_e( 'Search for:', 'bbpress' ), bbp_search_terms(), esc_attr_e( 'Search', 'bbpress' ) ); return $html; } );Then you can add that with the:
[my_bb_search]shortcode instead.March 27, 2023 at 6:23 am #2583987Riccardo
Hey David, thanks a lot. Almost done. It works, but I get a funky “Search for:Search” below my logo.
March 27, 2023 at 8:41 am #2584338David
StaffCustomer SupportHmmm… thats not going to work.
Try this PHP Snippet instead:add_shortcode( 'my_bb_search', function() { ob_start(); ?> <div class="bbp-search-form"> <form role="search" method="get" id="bbp-search-form"> <div> <label class="screen-reader-text hidden" for="bbp_search"><?php esc_html_e( 'Search for:', 'bbpress' ); ?></label> <input type="hidden" name="action" value="bbp-search-request" /> <input type="text" placeholder="Enter your search" value="<?php bbp_search_terms(); ?>" name="bbp_search" id="bbp_search" /> <input class="button" type="submit" id="bbp_search_submit" value="<?php esc_attr_e( 'Search', 'bbpress' ); ?>" /> </div> </form> </div> <?php return ob_get_clean(); } );March 27, 2023 at 9:03 am #2584378Riccardo
Beautiful! Thank you for your time David, very much appreciate it.
March 27, 2023 at 9:42 am #2584447David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.