首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用自定义dashboard.php的快速草稿小部件( post_type )

使用自定义dashboard.php的快速草稿小部件( post_type )
EN

WordPress Development用户
提问于 2020-02-05 03:34:49
回答 1查看 293关注 0票数 0

我试图修改WP仪表板小部件“快速草稿”,以接受自定义的post_type avada_portfolio (Avada主题),但是页面只挂起每个提交测试。

这里有一个类似的问题:添加自定义分类法以按下此面板

一位成员提到他们成功了,但不幸的是,他们取消了他们的榜样,因为这篇文章是关于“按这个”。

我想知道我是否正确地调用了post_type。任何帮助都将受到感激。据我所知这是:

代码语言:javascript
复制
/**
 * The Quick Draft widget display and creation of drafts.
 *
 * @since 3.8.0
 *
 * @global int $post_ID
 *
 * @param string $error_msg Optional. Error message. Default false.
 */
function wp_dashboard_quick_press( $error_msg = false ) {
    global $post_ID;

    if ( ! current_user_can( 'edit_posts' ) ) {
        return;
    }

    /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */
    $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID
    if ( $last_post_id ) {
        $post = get_post( $last_post_id );
        if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore
// MY REMOVE - $post = get_default_post_to_edit( 'post', true );
            $post = get_default_post_to_edit( $post_type = 'avada_portfolio', true );
            update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
        } else {
            $post->post_title = ''; // Remove the auto draft title
        }
    } else {
// MY REMOVE - $post    = get_default_post_to_edit( 'post', true );
        $post    = get_default_post_to_edit( $post_type = 'avada_portfolio', true );
        $user_id = get_current_user_id();
        // Don't create an option if this is a super admin who does not belong to this site.
        if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) {
            update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID
        }
    }

    $post_ID = (int) $post->ID;
    ?>

    

        
        
        

        
            
                
            
            
        

        
            
            
        

        
            
            
            
            
             'save-post' ) ); ?>
EN

回答 1

WordPress Development用户

发布于 2020-02-05 21:53:50

因此,快速草稿小部件似乎是在没有提供钩子的情况下在三个地方硬编码的。

我决定沿着wp_insert_post路线写我自己的插件:)

票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/357890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档