Skip to content

Instantly share code, notes, and snippets.

@gatespace
Last active February 10, 2017 03:52
Show Gist options
  • Select an option

  • Save gatespace/fcf6516e98be84847bee2cfff1cb8514 to your computer and use it in GitHub Desktop.

Select an option

Save gatespace/fcf6516e98be84847bee2cfff1cb8514 to your computer and use it in GitHub Desktop.
WordPress 抜粋と「続きを読む」のカスタマイズ小ネタ ref: http://qiita.com/gatespace/items/61e40a5bdb30a4f80a83
<?php
/**
* Filter the except length to 20 characters.
*
* @param int $length Excerpt length.
* @return int (Maybe) modified excerpt length.
*/
function wpdocs_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'wpdocs_custom_excerpt_length', 999 );
<?php
/**
* Filter the excerpt "read more" string.
*
* @param string $more "Read more" excerpt string.
* @return string (Maybe) modified "read more" excerpt string.
*/
function wpdocs_excerpt_more( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'wpdocs_excerpt_more' );
<?php
$wpmp_conf['excerpt_mblength'] = 10;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment