简体   繁体   中英

How to set a string length on wysiwyg text? (Wordpress)

Is it possible to cut the length of a string in the wysiwyg editor? I have set up some custom post types and on the archive page I want to be able to set a string length limit, if that limit is reached I also want to add ... to the end of it. Some of these posts have multiple paragraphs incase thats an issue.

I have tried many solutions like the following that don't work;

<?php echo mb_strimwidth( get_field('event_information'), 0, 10, '…'); ?>

I've used this before:

<p class="excerpt">
  <?php $customexerpt = get_the_content(); echo wp_trim_words( $customexerpt , '15' ); ?>
</p> 

But using the excerpt field is probably recomended.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM