Archived topic
generate_after_header_content spacing and layout
13 replies · Started by Richard on March 16, 2022
I’m trying to add elements to the generate_after_header_content and can’t seem to figure out how to keep the text in those blocks from wrapping to the next line, especially when there is soooo much room in the search bar. I know it’s got flex in there but I’m not familiar with that.
Hi Richard,
To have a better understanding of the issue, may you kindly add the Element and send a screenshot of the issue with a description of how you would like it to look like?
Hope to hear from you soon. :)
Look how much room there is for the search bar and how tight it is for the two elements after the search. I need to give those elements room to breathe and now wrap to the next line
https://watch.screencastify.com/v/LjYvFIKjnF3p8pSbR1gG
I see. Thank you for including a screen recording.
To confirm, are you wanting something like this?: https://share.getcloudapp.com/2NuzBpYB
If so, here is a CSS code you may try:
.woo-search {
flex-grow: 4;
}
.header-widget {
flex-grow: 1;
}
.wp-block-columns .wp-block-column {
text-align:right;
}
Here is an article with regards to adding CSS: https://docs.generatepress.com/article/adding-css/#additional-css
Adding this through additional CSS should work.
Hope this helps! Kindly let us know if you prefer something else. :)
Thank you! How can I get the cart up into the generate_after_header_content before or after Login? https://watch.screencastify.com/v/2eLGlvnRdNzS4QiDjLI4
You can hook this PHP code:
<?php echo generatepress_wc_cart_link(); ?>
Example: https://share.getcloudapp.com/Z4u7LjZZ
Hope this helps! Kindly let us know how it goes. :)
That got us halfway there. It appears in that location but doesn't have the hover and display of mini cart as the "normal" one does. (also, would like to remove it from the normal location once functioning properly)
Try this PHP snippet:
add_action('generate_after_header_content','generate_woo_cart');
function generate_woo_cart(){
if ( ! class_exists( 'WooCommerce' ) ) {
return;
}
if ( ! isset( WC()->cart ) ) {
return;
}
$has_items = false;
if ( ! WC()->cart->is_empty() ) {
$has_items = 'has-items';
}
printf(
'<span class="menu-bar-item wc-menu-item %2$s %3$s">
%1$s
</span>',
generatepress_wc_cart_link(),
is_cart() ? 'current-menu-item' : '',
$has_items
);
}
Adding PHP: https://docs.generatepress.com/article/adding-php/
There are now three carts and the mini cart visibility seems to have gotten worse.
1.Remove the hook with Fernando's code.
2.Disable the cart in customizer > layout > Woocommerce
OK, thank you. It's no longer aligned with the icon, though. How can I fix that? I tried `.wc-mini-cart {
right: 100px;}` but it didn't seem to work
This is what I see, not sure what do you mean by "it's no longer aligned with the icon?"
https://www.screencast.com/t/0IrtHK8B8Dku
Can you describe it more specifically?
I think it's working now. Maybe it was cached. We can close this now. I will start a new thread if I have further questions.
Thanks!
Glad to hear that :)