Created
October 11, 2019 06:04
-
-
Save UraraReika/49c3a2b4e077dd508e05138c539cd8fb to your computer and use it in GitHub Desktop.
Create Custom callback for Jet Posts Widgets that crops the transferred text to the specified number of words.
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 | |
add_filter( 'jet-elements/posts/meta_callbacks', '__your_prefix_add_meta_callback' ); | |
function __your_prefix_add_meta_callback( $callbacks ) { | |
$callbacks['__your_prefix_get_post_words_trim'] = esc_html__( 'Words Trim', 'jet-elements' ); | |
return $callbacks; | |
} | |
function __your_prefix_get_post_words_trim( $content ) { | |
$trimmed_content = wp_trim_words( $content, 40, '<a href="'. get_permalink() .'"> ...Read More</a>' ); | |
return $trimmed_content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment