0

I wanted to use css codes on certain post type with certain post status so i'm looking for a correct conditionals to use.

How can i detect this if it's edit.php & post_status = draft& post_type = food?

Example: domain.com/wp-admin/edit.php?post_status=draft&post_type=food

Tried the code below but it didnt work.

if(isset($_REQUEST['post_status']) && $_REQUEST['post_status'] == 'custom' ) { 
   echo '<style>tr.status-custom{ display: none; }</style>';
   }

PS: I basically want to hide posts (tr.status-draft) with drafts or any custom statuses using css so it doesn't appear on "all post" but appears when the Their designated post_status is set. So i basically can't do it with css alone because they will also be hidden even if the post_status action is set. So i really need a correct conditionals to use.

1 Answer 1

1

Post type is reflected in body as class. It is .post-type-post for posts, .post-type-product for WooCommerce products and must be .post-type-food in your case. So, you can use css rule like that to detect certain post type:

body.post-type-food #titlediv input {
    background: yellow !important;
}

Post status is reflected only in TinyMCE editor classes, as .post-status-draft. You can use it as follows:

body#tinymce.post-status-draft {
    background: red;
}
4
  • I basically want to hide posts (tr.status-draft) with drafts or any custom statuses using css so it doesn't appear on "all post" but appears when the Their designated post_status is set. So i basically can't do it with css alone because they will also be hidden even if the post_status action is set. Jan 13, 2018 at 10:36
  • The word "hide" is absent in your question. Otherwise I would tell you that it is impossible via css. Jan 13, 2018 at 10:38
  • Yea, i was actually looking for a conditionals to display my css code. Sorry i have updated my post. Thnks Jan 13, 2018 at 11:08
  • I do not understand your intentions. Please show the screenshot of the page /edit.php?post_status=draft&post_type=food pointing the elements you want to hide. Jan 13, 2018 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.