This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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