是否可以将文章页面上的摘录字段限制为文字?请注意,我知道可以重复摘录并限制其文字,但我希望字段本身限制字数,类似于文本区域的字符限制。
Is such thing possible? 也许是Javascript解决方案?也许类似于this plugin 对角色生物字段执行(尽管其限制基于角色数量)。
这是因为我运行了一个多作者平台,在这个平台上,用户经常会犯错误,超过帖子列表中打印的字数限制。
是否可以将文章页面上的摘录字段限制为文字?请注意,我知道可以重复摘录并限制其文字,但我希望字段本身限制字数,类似于文本区域的字符限制。
Is such thing possible? 也许是Javascript解决方案?也许类似于this plugin 对角色生物字段执行(尽管其限制基于角色数量)。
这是因为我运行了一个多作者平台,在这个平台上,用户经常会犯错误,超过帖子列表中打印的字数限制。
你可以使用jQuery Simply Countable plugin 并将其附加到摘录输入。
Limit_Excerpt_Words::on_load();
class Limit_Excerpt_Words {
static function on_load() {
add_action( \'admin_enqueue_scripts\', array( __CLASS__, \'admin_enqueue_scripts\' ) );
}
static function admin_enqueue_scripts() {
global $hook_suffix;
if ( \'post.php\' == $hook_suffix || \'post-new.php\' == $hook_suffix ) {
wp_enqueue_script( \'jquery-simply-countable\', plugins_url( \'/jquery.simplyCountable.js\', __FILE__ ), array( \'jquery\' ), \'0.4.2\', true );
add_action( \'admin_print_footer_scripts\', array( __CLASS__, \'admin_print_footer_scripts\' ) );
}
}
static function admin_print_footer_scripts() {
?>
<script type=\'text/javascript\'>
jQuery(document).ready(function ($) {
$(\'#excerpt\').simplyCountable({
countType:\'words\', maxCount:5, strictMax:true
});
});
</script>
<span id="counter" style="display:none;"></span><!-- needs counter to work -->
<?php
}
}
PS还有word-count.js
在WP core中,但我无法理解它是否可以轻松地用于阻止内容。我正在上使用以下循环index.php.当前查看的页面将是循环中的链接之一How to make sure it is marked as current?<ul id=\"questions\" class=\"subpage\"> <?php $index_query = new WP_Query( array( \'post_type\' => \'faq\', \'orderby\' => \'modifie