• Resolved jonwatson87

    (@jonwatson87)


    Hey! Great plugin πŸ™‚

    Is it possible to hide the “rate my post” meta field/admin section in the admin panel post edit screens? (https://domain.com/wp-admin/post.php?post=XXXX&action=edit)

    I’m manually adding via the shortcode to my “post” post type on the front end, but would like to disable the rating box from appearing on all my other post types on the back end…

    Is there a way of turning it off/disabling it, and just keeping it on the default “post” post type edit screen?

    Many thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Blaz K.

    (@blazk)

    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

    Thread Starter jonwatson87

    (@jonwatson87)

    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

    Thread Starter jonwatson87

    (@jonwatson87)

    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');
    
    Thread Starter jonwatson87

    (@jonwatson87)

    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…

    Plugin Support Blaz K.

    (@blazk)

    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

    Thread Starter jonwatson87

    (@jonwatson87)

    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! πŸ˜€

    Plugin Support Blaz K.

    (@blazk)

    Happy to hear that! πŸ™‚

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Hide on post edit screens’ is closed to new replies.