Top Menu

  • What is a Snippet?
  • Add a Snippet
  • Contact Us
Navigation

WPCodebook

Re-usable WordPress source code database

Home

Primary Menu

Return to Content

Control excerpt length in WordPress

  • PHP, WordPress
  • Snippets
  • Mekas
  • December 24, 2014
function custom_excerpt_length( $length ) {
	return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Show trailing zeros on prices in WooCommerce

  • PHP, WooCommerce, WordPress
  • Snippets
  • Mekas
  • December 24, 2014
// Show trailing zeros on prices, default is to hide it.
add_filter( 'woocommerce_price_trim_zeros', 'wc_hide_trailing_zeros', 10, 1 );
function wc_hide_trailing_zeros( $trim ) {
    // set to false to show trailing zeros
    return false;
}
← Previous 1 … 23 24

Top Snippets

  • Get product SKU by product ID in WooCommerce
  • Hide the date of product's review in WooCommerce with CSS
  • Determine if WordPress user is a WooCommerce shop manager
  • Delete posts old slugs from database in WordPress
  • Get WooCommerce product shipping class name
  • Automatically add WooCommerce product subcategories to categories in menu
  • Set WordPress user registration date with PHP

WPCodebook © 2023. All Rights Reserved.