发布帖子后,我想显示我自己的(2)admin\\U通知。
我该怎么做?
P、 s:我需要这个来显示我的外部功能的结果。
谢谢
发布帖子后,我想显示我自己的(2)admin\\U通知。
我该怎么做?
P、 s:我需要这个来显示我的外部功能的结果。
谢谢
add_action(\'admin_notices\', function(){
$screen = get_current_screen();
$editPostScreen = ($screen->parent_base == \'edit\' && $screen->post_type == \'post\') ? true : false;
$justPublished = (isset($_GET[\'message\']) && $_GET[\'message\'] == \'6\') ? true : false;
if ($editPostScreen && $justPublished) {
$class = \'notice notice-info\';
$message = __( \'Just published a post custom text\', \'myplugin_textdomain\' );
printf( \'<div class="%1$s"><p>%2$s</p></div>\', esc_attr( $class ), esc_html( $message ) );
}
});
($justPublished
依赖于$_GET[\'message\']
. 此URL查询变量在管理地址栏中不可见,实际上是Wordpressremoves it from the URL with Javascript! 我花了很长时间才弄明白,所以虽然你看不到它,但它确实存在!)编辑默认的“已发布”通知,您可以使用以下命令edit 发布帖子后的管理员通知:
add_filter( \'post_updated_messages\', function($messages){
$messages[\'post\'][6] = __( \'Just published a post custom text\', \'myplugin_textdomain\' );
return $messages;
}, 10, 1 );
我很难让插件正常工作Virtual Pages (WordPress插件可简化虚拟页面的创建)我确实进行了编辑,根据查询创建了一个循环。add_action( \'gm_virtual_pages\', function( $controller ) { /* Creating virtuals pages for companies */ $args = array( \'post_type\' => array(\'companies\',), \'post_status\'