Skip to content

Instantly share code, notes, and snippets.

@UraraReika
Created October 11, 2019 06:04
Show Gist options
  • Save UraraReika/49c3a2b4e077dd508e05138c539cd8fb to your computer and use it in GitHub Desktop.
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.
<?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