Skip to content

Instantly share code, notes, and snippets.

@stillatmylinux
Last active January 24, 2017 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stillatmylinux/8ae2f3096ec992e30ab3e044a97b9d44 to your computer and use it in GitHub Desktop.
Save stillatmylinux/8ae2f3096ec992e30ab3e044a97b9d44 to your computer and use it in GitHub Desktop.
<?php
/**
* @author AppPresser
*
*
* If you would like to shorten the title
* when using the AppSwiper plugin for the
* product post_type.
*
* Place this code your child theme's functions.php
*/
add_filter('the_title', 'my_woo_swiper_title');
function my_woo_swiper_title( $title ) {
global $post;
$max_words = 5;
if( isset( $post, $post->post_type ) && $post->post_type == 'product' ) {
$short_title = '';
$words = explode( ' ', $title);
for($i=0; $i<=$max_words;$i++) {
$short_title .= $words[$i] . ' ';
}
$title = trim($short_title);
}
return $title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment