This tutorial provides the code to automatically add space separated category slugs as classes to nav menu items that link to single posts in WordPress. Could be useful for styling the menu items based on categories when using a plugin like Category Posts in Custom Menu. Add the following in child theme’s functions.php: To view […]
Code Snippets
How to load WooCommerce CSS and JS only on shop-specific pages in WordPress
Update on 7 Mar 2022: Follow this updated tutorial instead. — When you have a WooCommerce-powered shop in your WordPress site, assets like the following may be loading on all the pages of the site (depending on what plugins/services/theme are/is active): woocommerce-layout.csswoocommerce-smallscreen.csswoocommerce.csstwenty-seventeen.css add-to-cart.min.jsjquery.blockUI.min.jsjs.cookie.min.jswoocommerce.min.jscart-fragments.min.js If you do not have a “Add to Cart” feature in your […]
Genesis Community Wiki
I have been working for the last couple of days on putting together code snippets that anyone in the Genesis community can add to and edit. Pleased to announce the launch of collaborative code snippets where anyone in the #GenesisWP community can contribute.https://t.co/W7EdIm4cNh Register an account, log in and start adding your code collection. — […]
How to rotate widgets in Primary and Secondary sidebars in WordPress
In the Genesis Facebook group, a user asked: how do i automagically rotate widgets in both the primary and secondary sidebars, on screen refresh? where do i find the index names of sidebars? Adding the following in child theme’s functions.php will shuffle and display widgets of Primary and Secondary sidebars in random order on page […]
Conditional layouts for WooCommerce product archives based on parent category
In the members-only forum, a user asked: I’m trying to show or hide the sidebar using the full-width-content or sidebar-content layout on categories depending on the parent category in WooCommerce. I have a lot of sub categories so don’t want to do it manually in the archive setting of each category. I also need to […]
How to change product image thumbnail size on Easy Digital Downloads checkout page
By default product thumbnails on EDD checkout page appear very tiny (25 x 25). Here’s the code snippet to set a custom image size for the same: add_filter( ‘edd_checkout_image_size’, ‘filter_edd_checkout_image_size’, 10, 1 ); /** * Change product image thumbnail size on Easy Digital Downloads checkout page. * * @param array $array default image size (25 […]
How to insert HTML between Title Area and Header Widget Area in Genesis
If you are looking to inject custom HTML markup, say a div in between .title-area and .header-widget-area in Genesis it can be done using the genesis_markup_<context-name>_<open/close> dynamic filter hook. In a function hooked to genesis_markup_title-area_close filter, we can check for a closing tag of .title-area, append our custom HTML markup to it and return the […]
How to remove Dates from Posts in Genesis
Looking to get rid of dates from appearing in the post info text in your Genesis site? Add the following in child theme’s functions.php: add_filter( ‘genesis_post_info’, ‘sp_post_info_filter’ ); /** * Customize entry meta in the entry header. * * @param string $post_info Existing post info * @return Modified post info */ function sp_post_info_filter( $post_info ) […]
How to remove Primary Navigation Menu from WooCommerce pages in Genesis
In Facebook Genesis group, a user asked: I’m using Cafe Pro and I want to remove the menu from my WooCommerce pages only. I’ve looked through the functions file to try and find where it’s hooked in, but I don’t see it. Can someone point me in the right direction, please? Primary nav menu (genesis_do_nav()) […]
How to display word count for posts in Genesis
Adding the following in child theme’s functions.php will display the word count in post info on single post pages in Genesis: add_shortcode( ‘word_count’, ‘func_word_count’ ); /** * Register custom [word_count] shortcode to display the number of words in a post. * * @return word count. */ function func_word_count() { $content = get_post_field( ‘post_content’, get_the_ID() ); […]
Recent Comments