Created
November 5, 2022 06:55
-
-
Save azizulDev/f6fe40c547eba3eb7ccf2218db24e8ac to your computer and use it in GitHub Desktop.
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
remove_action('post_grid_layout_element_excerpt', 'post_grid_layout_element_excerpt'); | |
add_action('post_grid_layout_element_excerpt', 'post_grid_layout_element_excerpt_1152022'); | |
function post_grid_layout_element_excerpt_1152022($args){ | |
$element = isset($args['element']) ? $args['element'] : array(); | |
$elementIndex = isset($args['index']) ? $args['index'] : ''; | |
$post_id = isset($args['post_id']) ? $args['post_id'] : ''; | |
if(empty($post_id)) return; | |
$layout_id = isset($args['layout_id']) ? $args['layout_id'] : ''; | |
$post_excerpt = get_the_excerpt($post_id); | |
$post_link = get_permalink($post_id); | |
$link_target = isset($element['link_target']) ? $element['link_target'] : ''; | |
$custom_class = isset($element['custom_class']) ? $element['custom_class'] : ''; | |
$char_limit = isset($element['char_limit']) ? (int) $element['char_limit'] : 0; | |
$read_more_text = isset($element['read_more_text']) ? $element['read_more_text'] : __('Read more', 'post-grid'); | |
if($char_limit > 0){ | |
$post_excerpt = wp_trim_words($post_excerpt, $char_limit, ''); | |
} | |
?> | |
<div class="element element_<?php echo esc_attr($elementIndex); ?> <?php echo esc_attr($custom_class); ?> excerpt "> | |
<?php echo do_shortcode($post_excerpt); ?> | |
<?php | |
if(!empty($read_more_text)): | |
?> | |
<a target="<?php echo esc_attr($link_target); ?>" href="<?php echo esc_url_raw($post_link); ?>"><?php echo esc_html($read_more_text); ?></a> | |
<?php | |
endif; | |
?> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment