- This topic has 21 replies, 3 voices, and was last updated 1 year, 6 months ago by
David.
-
AuthorPosts
-
December 7, 2020 at 6:55 am #1570461
ahmad
Hello Guys
I want to add a search bar hero element under the header bar
like in this image :I have managed to add PHP snippet this one with pluginception
add_shortcode( ‘search_form’, function() {
ob_start();get_search_form();
return ob_get_clean();
} );and then created a hook before the main content and added this :
[search-form]
but the result is ugly not centered and cant color it and doesn’t seem to work:
can you guys help to reach a good result?
best
December 7, 2020 at 7:42 am #1570515David
StaffCustomer SupportHi there,
create a Block Element and set the Hook to
generate_after_header
https://docs.generatepress.com/article/block-element-overview/
You can use the GenerateBlocks plugin to create the Container, add background etc and other content, to which you can also include your search Shortocde to.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 7, 2020 at 8:04 am #1570540ahmad
Thanks for Getting Back David
Alright I was able to get this started
but now how can I alter the look of the search bar itself
– I want to make it longer
– I want to change the button color, shape, size ( rounder, square )
– I want to change the word inside the bar ( Search… )
I cannot do that within the block editor
can you please help?December 7, 2020 at 8:44 am #1570573ahmad
Another Question on mobile
that search bar gets messed up there is no padding between the text field and button
and it’s not centered at all here is how it looks like :December 7, 2020 at 11:09 am #1570702David
StaffCustomer SupportIf you can share a link to a page where i can see this then ill provide some CSS.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 7, 2020 at 11:12 am #1570707ahmad
Sure
Designscanyon.com
Please also check on mobile
ThanksDecember 7, 2020 at 3:58 pm #1570947Elvin
StaffCustomer SupportHi,
To clarify: Are you trying to achieve an alignment similar to this?
https://share.getcloudapp.com/Jruq6QPPIf so, you can try adding this CSS:
.gb-inside-container form.search-form { display: flex; justify-content: center; }
This CSS center aligns the contents of the search form.
A wise man once said:
"Have you cleared your cache?"December 8, 2020 at 12:34 am #1571216ahmad
Thank you, Elvin
that fixed the alignment for surecan you please tell me how to change:
– button color
– the wording inside the search boxalso for some reason on mobile the text field has rounded corners but on the desktop is different
do you know why and how to make it corners on all devices?Thanks
December 8, 2020 at 3:10 am #1571375David
StaffCustomer SupportTo change the Placeholder text you will need to change your search from shortcode to this:
add_shortcode( 'search_form', function() { ob_start(); ?> <form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>"> <label> <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span> <input type="search" class="search-field" placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ) ?>" value="<?php echo get_search_query() ?>" name="s" title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" /> </label> <input type="submit" class="search-submit" value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" /> </form> <?php return ob_get_clean(); } );
On this line of the code:
placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ) ?>
Change the
Search ...
text to what you require.
Once that is done we may need to tweak the CSS – so make that change and let us know and we can work through the other amends.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 8, 2020 at 3:14 am #1571376ahmad
Hello David Yes that worked Thank you
still left:
-Change button Color
-fix the rounded text field in mobile
Best
December 8, 2020 at 3:15 am #1571378ahmad
also if there is a way to make the search field width longer ?
December 8, 2020 at 6:14 am #1571538David
StaffCustomer Supporthmmm … you’re using a Grid Block with empty columns to restrict the size of your content. Don’t use the Grid Block, simply place the content inside the Container block, in the settings > Layout you can change the width of the inner container.
Need that change so as i can resize the search bar.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 10, 2020 at 1:28 am #1573978ahmad
Can you please tell me how to change the button color?
ThanksDecember 10, 2020 at 4:28 am #1574158David
StaffCustomer SupportBy default that button will use the Colors you set in Customizer > Colors > Buttons
If you want it to be different to the rest of the theme then use this CSS:.search-form input[type=submit] { background-color: #f00; color: #000; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 10, 2020 at 4:45 am #1574185ahmad
Thank you David that changed the color!
The only thing I have left is the actual width of the search field I would like to make it longer.
I did what you said in the block editor I removed all the columns as a test and keep only the short code one but still, it was the same width it wasn’t longer
any ideas what could be the issue?
Best
-
AuthorPosts
- You must be logged in to reply to this topic.