duandi4238 2018-01-29 19:08
浏览 27
已采纳

启用“帖子格式”只是为了“自定义帖子类型”而不是WordPress中的其他人

I've been struggling with Post Formats and CPTs in WordPress and after many hours, I decided to create some CPTs and enable Post Formats for them.

The problem is, when I enable Post Formats, they become available for all of the post types; and I want to have them just for some of the CPTs and not other ones.

Assume I have three CPTs called "article", "webinar" and "tutorial" . I want to enable Post Formats just for "webinar".

What I've done is to create a plugin and enable Post Formats with:

add_theme_support( 'post-formats', array( 'audio', 'image', 'video', 'gallery' ));

after that, I tried to enable them for CPT which is called medya:

add_post_type_support( 'medya', 'post-formats');

and then, I tried to disable them for defalut "post" post type.

remove_theme_support( 'post', 'post-formats');

But it doesn't work and Post Formats are enabled for both. Any suggestions?

  • 写回答

2条回答 默认 最新

  • doujiao9574 2018-02-01 07:43
    关注

    Answered

    I found the answer here.

    function remove_pf() {
        remove_meta_box( 'formatdiv','post','normal' );
    }
    add_action( 'admin_menu', 'remove_pf' );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥23 (标签-bug|关键词-密码错误加密)
  • ¥66 比特币地址如何生成taproot地址
  • ¥20 数学建模数学建模需要
  • ¥15 关于#lua#的问题,请各位专家解答!
  • ¥15 什么设备可以研究OFDM的60GHz毫米波信道模型
  • ¥15 不知道是该怎么引用多个函数片段
  • ¥30 关于用python写支付宝扫码付异步通知收不到的问题
  • ¥15 隐藏系统界面pdf的打印、下载按钮
  • ¥15 基于pso参数优化的LightGBM分类模型
  • ¥15 安装Paddleocr时报错无法解决