0

Is there a way to disable the sticky option on posts in specific categories?

  • 1
    Maybe, yes. What did you find in your research? – brasofilo Jan 22 '13 at 22:35
  • Nothing, that's the problem. I keep getting pages of irrelevant search results. – Force Flow Jan 23 '13 at 14:32
  • Maybe there's nothing more to say about it, but I find strange a one line Question with the_title == the_content... Much probably this is a jQuery solution, I've answered quite a few. And an inside research on Sticky Posts. – brasofilo Jan 23 '13 at 14:45
0

I ended up going with another approach. I check to see what the current user's role is, then if the role is 'author', enqueued a CSS file to hide the sticky option's checkbox.

In the theme's functions.php file:

function hide_sticky_option($hook) {
    global $current_user;

    if('post.php'== $hook || 'post-new.php'==$hook){
        $role = array_shift($current_user->roles); //get role of current user
        if($role=='author'){ //if role of current user is 'author'
            wp_enqueue_style('hide_sticky_option', get_template_directory_uri() . '/css/admin-post-style.css' );
        }
    }
}
add_action( 'admin_enqueue_scripts', 'hide_sticky_option' );

admin-post-style.css:

#sticky-span {
    display:none !important;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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