WordPress.org

Ready to get started?Download WordPress

Forums

truncate post with gallery tag (1 post)

  1. dados
    Member
    Posted 1 year ago #

    I have one problem I use this function for truncate posts

    function truncate_post($amount,$quote_after=false) {
    	$truncate = get_the_content();
    	$truncate = apply_filters('the_content', $truncate);
    	$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);
    	$truncate = preg_replace('@<style[^>]*?>.*?</style>@si', '', $truncate);
    	$truncate = strip_tags($truncate);
    	$truncate = substr($truncate, 0, strrpos(substr($truncate, 0, $amount), ' '));
    	echo $truncate;
    	echo "...";
    	if ($quote_after) echo('');
    }

    but in my posts there is wordpress gallery call

    [gallery ids="614,592,591"]

    And now I need this truncate to not calculate this gallery tag.. because I get empty fields.. is this can be done? to truncate just text...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags