如何关闭媒体上传的评论

我希望在媒体上传时始终关闭评论(例如,带有 png 扩展名的图像)。对于新媒体,例如照片,应始终关闭评论。但是,我找不到解决方案。
基本上,当上传任何媒体时,以下 SQL 代码都可以使用,但这当然不是一个明智的解决方案:

UPDATE wp_postsSET comment_status= '关闭' WHERE post_type= '附件';

以下代码可以实现它的功能:

add_filter('comments_open', 'turn_off_comments_media', 10 , 2 );
function turn_off_comments_media( $open, $post_id = null ) {
$post_variable = get_post( $post_id );
if( $post_variable->post_type == 'attachment' ){ 
return false;
}

return $open;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
日主题系列

RiProV2美化-删除文章同时删除图片

2022-10-21 10:15:52

开发教程

如何从category.php页面上的 URL 回显一个或多个分类?

2022-10-21 11:49:37

18 条回复 A文章作者 M管理员
  1. I just could not leave your web site before suggesting that I really enjoyed the standard information a person supply to your visitors? Is gonna be again steadily in order to check up on new posts.

  2. Wow, wonderful blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is great, as well as the content!

  3. Hi, i think that i saw you visited my web site thus i came to ?eturn the favor텶’m attempting to find things to enhance my site!I suppose its ok to use a few of your ideas!!

  4. you are in reality a just right webmaster. The site loading velocity is incredible. It seems that you are doing any unique trick. In addition, The contents are masterwork. you have performed a wonderful task on this topic!

  5. Somebody essentially lend a hand to make significantly articles I’d state. That is the very first time I frequented your website page and up to now? I surprised with the research you made to make this actual submit amazing. Wonderful task!

  6. Nice blog here! Also your site loads up fast! What host are you using? Can I get your affiliate link to your host? I wish my web site loaded up as quickly as yours lol

  7. My brother recommended I might like this web site. He was totally right. This post actually made my day. You cann’t imagine just how much time I had spent for this information! Thanks!

  8. I do not even know how I ended up here, but I thought this post was great. I do not know who you are but certainly you’re going to a famous blogger if you are not already 😉 Cheers!

  9. Thanks, I have recently been looking for info about this subject for a while and yours is the greatest I have discovered so far. However, what in regards to the bottom line? Are you certain in regards to the supply?

  10. Hello, i think that i saw you visited my weblog so i came to ?eturn the favor텶’m trying to find things to improve my web site!I suppose its ok to use some of your ideas!!

  11. Hi my family member! I want to say that this post is awesome, nice written and come with approximately all significant infos. I would like to peer extra posts like this.

  12. I have been surfing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the web will be much more useful than ever before.

  13. obviously like your web-site but you need to test the spelling on quite a few of your posts. Several of them are rife with spelling problems and I to find it very troublesome to inform the reality on the other hand I’ll certainly come back again.

  14. Thank you, I have just been searching for information approximately this topic for a while and yours is the best I have found out so far. However, what in regards to the bottom line? Are you certain concerning the supply?

  15. Hi, i think that i saw you visited my web site thus i came to ?eturn the favor텶’m attempting to find things to enhance my site!I suppose its ok to use a few of your ideas!!

  16. Magnificent beat ! I would like to apprentice while you amend your site, how can i subscribe for a blog web site? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear idea

  17. I just could not depart your web site prior to suggesting that I really loved the usual info an individual supply in your visitors? Is gonna be back regularly to check up on new posts.

  18. I loved as much as you will receive carried out right here. The sketch is attractive, your authored material stylish. nonetheless, you command get got an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this hike.

个人中心
今日签到
有新私信 私信列表
搜索
赣ICP备2021010644号-1