Created
July 4, 2023 19:46
-
-
Save nfsarmento/41e8fb7ff8e484fbb02a2363d07919d1 to your computer and use it in GitHub Desktop.
Shortcode to show post title truncated
This file contains hidden or 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 | |
/** | |
* | |
* Shortcode to show post title truncated | |
* | |
* [posttitle] | |
* | |
*/ | |
function ns_post_title_shortcode(){ | |
return wp_trim_words( get_the_title(), 10 ); | |
} | |
add_shortcode( 'posttitle', 'ns_post_title_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment