I’m adding TinyMCE buttons to my plugin and they’re working, but I only want these buttons to show up for a certain custom post type. I followed this tutorial if it helps:
http://www.tutorialchip.com/wordpress/wordpress-shortcode-tinymce-button-tutorial-part-2/
How can I have that check if they are editing/posting a post in a custom post type of lets say, newpages
?
If you followed that tutorial you linked then look at the function that registers the buttons:
and you change it a bit to check for the post type:
this way you only register the buttons on your “newpages” type
Thank you Bainternet. Very useful. I used your solution with one small modification.
Instead of
I took
$typenow only returns the correct type, if you are inserting a new post. When you are editing an existing post, it always returns “post”. So it’s better to use $current_screen->post_type.