Tagged: enfold, shortcode, woocommerce
-
AuthorPosts
-
January 31, 2022 at 8:19 pm #1338084
How would someone get a subnavbar inserted on pages within a site with WooCommerce?
So, the site navigation is better handled by the sub navbar element than the primary navigation element. So, knowing that messing with Woo and Enfold should be minimal, I tried to insert just a shortcode for a subnavbar.
[av_submenu which_menu='' menu='23' position='center' sticky='aviaTBsticky' color='footer_color' mobile='disabled' mobile_switch='av-switch-768' alb_description='' id='subnav' custom_class='subnav' template_class='' av_uid='av-ndlzm' sc_version='1.0'] [av_submenu_item title='Menu Item 1' button_style='' link='' linktarget='' av_uid='av-gg26y' sc_version='1.0'] [av_submenu_item title='Menu Item 2' button_style='' link='' linktarget='' av_uid='av-ba2z6' sc_version='1.0'] [/av_submenu]
But, as II half expected, it would not render that out to a navbar. Is there an easy way to allow for elements like these on Woo pages?
February 1, 2022 at 6:28 am #1338154Hey Jason,
Thank you for the inquiry.
Where did you add the shortcode? Instead of adding the shortcode directly to a text editor, you can use template hooks to place the element wherever you want. To place the sub navigation above the product loop, try to use this hook.
add_action("woocommerce_before_main_content", function() { if( ! is_shop() ) return; $menu = do_shortcode("[av_submenu which_menu='' menu='23' position='center' sticky='aviaTBsticky' color='footer_color' mobile='disabled' mobile_switch='av-switch-768' alb_description='' id='subnav' custom_class='subnav' template_class='' av_uid='av-ndlzm' sc_version='1.0'] [av_submenu_item title='Menu Item 1' button_style='' link='' linktarget='' av_uid='av-gg26y' sc_version='1.0'] [av_submenu_item title='Menu Item 2' button_style='' link='' linktarget='' av_uid='av-ba2z6' sc_version='1.0'][/av_submenu]"); echo "<div class='av-shop-sub-nav'>" . $menu . "</div>"; }, 10);
Best regards,
IsmaelFebruary 4, 2022 at 11:32 pm #1338966Thank you! That works beautifully!
Sorta related question. Is there anything within Enfold/Avia that would strip shortcodes from a product short description field? I have used the function WooCommerce gives to allow shortcodes in them, but something continues to strip any/all shortcodes/code out of the field upon save/update.
February 4, 2022 at 11:34 pm #1338967Oops, this is the function WooCommerce offers to allow shortcodes in the descriptions…
/**
* Allow shortcodes in product excerpts
*/
if (!function_exists(‘woocommerce_template_single_excerpt’)) {
function woocommerce_template_single_excerpt( $post ) {
global $post;
if ($post->post_excerpt) echo ‘<div itemprop=”description”>’ . do_shortcode(wpautop(wptexturize($post->post_excerpt))) . ‘</div>’;
}
}February 5, 2022 at 12:35 am #1338975Okay, so I have been digging into this more and more. Does Enfold save the short description field in a different place, like it does for post content in the meta table?
February 7, 2022 at 4:51 am #1339266Hi,
Thank you for the update.
The theme doesn’t alter the product description in any way as far as we know. You can check the enfold/config-woocommerce/config.php file to view the theme modifications for the shop plugin.
Where can we check the issue? Please provide the product URL in the private field.
Best regards,
IsmaelFebruary 13, 2022 at 1:01 am #1340327Thank you again. I think it was a plugin conflict, even though it should not have been.
So, I took your suggested code for adding the subnavbar to the shop pages global, as it looks more in line with the client’s content site. It looks nice, but has an odd issue on the store main page — it kicks the sidebar down below the product loop. Am I missing something obvious to avoid this? Here is the code I adapted from your’s.
add_action(“woocommerce_before_main_content”, function() {
$menu = do_shortcode(“[av_submenu which_menu='' menu='23' position='center' sticky='aviaTBsticky' color='footer_color' mobile='disabled' mobile_switch='av-switch-768' alb_description='' id='subnav' custom_class='subnav' template_class='' av_uid='av-ndlzm' sc_version='1.0'] [av_submenu_item title='Menu Item 1' button_style='' link='' linktarget='' av_uid='av-gg26y' sc_version='1.0'] [av_submenu_item title='Menu Item 2' button_style='' link='' linktarget='' av_uid='av-ba2z6' sc_version='1.0'][/av_submenu]“);
echo “<div class=’av-shop-sub-nav’>” . $menu . “</div>”;
}, 10);Beyond the sidebar issue, it brings me to wonder if there would be any way to achieve this as the primary navbar? I have tried and as you know with all the sites we do, we have experimented with lots of designs and customizations. But, what is getting me is how to have two separate color sections: one for the header and one for the navbar. It sounds easy, and maybe it is, but for the life of me, the process is eluding me.
Any ideas?
Thanks again for all of the help!
-jasonFebruary 18, 2022 at 4:31 am #1341254Hi,
it kicks the sidebar down below the product loop. Am I missing something obvious to avoid this? Here is the code I adapted from your’s.
Sorry for the delay. We are not seeing this issue on our end. The sidebar is perfectly positioned beside the content even though the fixed submenu is there. Would you mind providing a screenshot?
Best regards,
IsmaelMarch 9, 2022 at 9:10 pm #1343910I had to do a bunch of css work to fix the issue.
I still would be very interested in seeing a method to accomplish this as a main menu, rather than as a shortcode attached subnavbar element. Can there be some consideration for making the main nav its own for formatting? Currently, it resides within the Header element, which means it affects the entire header along with the navbar. For those using navbars below the logo, it would be really useful to be able to style that element on its own.
Hope this helps!
-jasonMarch 15, 2022 at 1:10 pm #1344556 -
AuthorPosts
- You must be logged in to reply to this topic.