Hi @jonwatson87,
something like this should do the trick (replace the id below with your post id):
add_action('admin_head', 'my_custom_style');
function my_custom_style() {
if( get_the_id() != 373 ) { //post id where to show meta box
echo '<style>
#rmp-rate-id {
display: none;
}
</style>';
}
}
Regards,
Blaz
Hey Blaz!
Thanks for this! But post ID has limited usefulness if I want it to display for all posts in the custom “post” post type, but none of my custom ones…
But the CSS hide is a good place to start.
Thanks!
Jon
FYI:
Think I’ve got it sorted.
Had to change the if statement, and hook into “current_screen”, rather than admin_head, but seems to do the trick π
// Hide Rating Manager on custom post type edit screens
function rtt_ratings_custom_style( $current_screen ) {
if ( is_admin() && 'post' !== $current_screen->post_type ) {
echo '<style>
#rmp-rate-id {
display:none;
}
</style>';
}
}
add_action('current_screen', 'rtt_ratings_custom_style');
Scratch that…
The hide works, and the code works, but the style element screws up CSS for the rest of the page when editing in Gutenberg.
The content/editing block section doesn’t automatically expand for content, instead spilling over and being hidden.
CSS may not fix this one…
Uf I read too fast π So, if you want to hide everywhere but in posts of type post then this should work:
add_action('admin_head', 'my_custom_style');
function my_custom_style() {
if( get_post_type() != 'post' ) { //post id where to show meta box
echo '<style>
#rmp-rate-id {
display: none;
}
</style>';
}
}
Blaz
You, sir, are a gentleman and a scholar! Works like a charm π
I could’ve sworn I tried that… but clearly must’ve had another check in there as well that was causing an error, like is_admin() or something.
But working great! Perfection. Thank you! π