get_the_excerpt() not returning anything when post has no excerpt

Double check that you don’t have a check for has_excerpt() that’s hiding the “auto-generated” excerpt. Even if get_the_excerpt() returns something made from post_content, has_excerpt() still returns false if the excerpt is empty. If that’s not the case, see if there’s a function that filters on get_the_excerpt that could be effecting this. To answer your question, … Read more

Adding Google Analytics to footer selectively

You have the ?> and ?php at wrong place, this way user logged in testing is a simple text. Try this: // add google analytics to footer function add_google_analytics() { if ( !is_user_logged_in() ) { ?> <!–Google Analytics–> <script type=”text/javascript”> var _gaq = _gaq || []; _gaq.push([‘_setAccount’, ‘UA-XXXXXXXX-X’]); _gaq.push([‘_trackPageview’]); _gaq.push([‘_trackPageLoadTime’]); (function() { var ga = … Read more

Hide some items from Screen options in dashboard for products

The best option would be to use CSS to hide these columns and fields. Add this in your admin.css file to hide the SKU column table.wp-list-table .column-sku { width: 10% } To hide options in Screen Options add the following CSS in admin.css .metabox-prefs label:nth-child(2), .metabox-prefs label:nth-child(11), .metabox-prefs label:nth-child(12) { display: none; } FYI to … Read more

How to add a rel attribute to images that contains their categories?

This should work for the rel attribute: /** * Create a rel attribute from the image categories * * @see http://wordpress.stackexchange.com/a/158024/26350 */ add_filter( ‘get_image_tag’, function( $html, $id ) { $rel = array(); foreach( (array) get_the_category( $id ) as $cat ) { $rel[] = $cat->slug; } return str_ireplace( ‘<img ‘, sprintf( ‘<img rel=”%s” ‘, join( ‘ … Read more

Change a sidebar name?

Hook into register_sidebar and change the name after the sidebar was registered. Example: add_action( ‘register_sidebar’, function( $sidebar ) { global $wp_registered_sidebars; if ( ‘Main Sidebar’ !== $sidebar[ ‘name’ ] ) return; $id = $sidebar[ ‘id’ ]; $sidebar[ ‘name’ ] = ‘Master’; $wp_registered_sidebars[ $id ] = $sidebar; }); There is no need to unregister the original … Read more