Skip to content

Instantly share code, notes, and snippets.

View MortenAndersen's full-sized avatar

Morten Andersen MortenAndersen

View GitHub Profile
@bhongy
bhongy / Wordpress: Do if the_content is not empty
Last active September 15, 2023 03:36
Wordpress: Check if the_content is empty / do something only when the_content is empty
<?php if ( get_the_content() ) { ?>
// do or output something
<?php } ?> // break php tag for HTML block
@rutger1140
rutger1140 / gist:5576437
Created May 14, 2013 14:38
Clean up WordPress wp_nav_menu
<?php
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
@ChromeOrange
ChromeOrange / product-tag.php
Last active December 15, 2015 15:18
WooCommerce : display products in a tag. Add to your theme functions.php file
/**
* List products in a product tag shortcode
* Useage : [product_tag tag="foo"]
*/
add_shortcode( 'product_tag', 'woocommerce_product_tag' );
function woocommerce_product_tag( $atts ){
global $woocommerce, $woocommerce_loop;
if ( empty( $atts ) ) return;