我刚刚得到一个答案my question 但问题是,我想打印一个错误,因为每个用户都会通过post-new.php
具有admin_notice
行动挂钩。
如何做到这一点?
我刚刚得到一个答案my question 但问题是,我想打印一个错误,因为每个用户都会通过post-new.php
具有admin_notice
行动挂钩。
如何做到这一点?
您可以使用函数add_settings_error
.
更多详细信息可以在Wordpress中找到documentation. 我编辑了您之前的回答,包括:
function wpse_189722_limit_tag_words( $term, $taxonomy ) {
if ($taxonomy === \'post_tag\') {
if ( count( preg_split( \'/\\s+/\', trim( $term ) ) ) > 2 ) {
add_settings_error(\'term_too_many_words\', \'term_too_many_words\', \'Maximum of 2 words allowed, but entered: \'. trim($term), \'error\');
// shorten the term to the allowed number of tags
$normalized_term = $foo = implode(\' \', array_slice(preg_split(\'/\\s+/\', trim($term)), 0, 2));
return $normalized_term;
}
}
return $term;
}
add_filter( \'pre_insert_term\', \'wpse_189722_limit_tag_words\', 10, 2 );
您还可以查看Wordpress通知的精美指南here.目前,我正在尝试执行一个非常基本的AJAX请求,只是为了测试功能,通过管理AJAX路由我的调用。php。然而,每次我尝试触发AJAX请求时,都会收到一个404错误,上面写着“未捕获的语法错误:意外的标记<;”。Wtf?这似乎是因为我的DTD中的carot。。。我已经检查了我的代码,但不知道我在这里做错了什么。。。我对AJAX的工作还比较陌生,所以如果有任何帮助,我将不胜感激。函数中的php。php什么都不是。。。function shows_callback(){ echo \'<