The Ajax way (a little bit dirty, but you can easily enhance it)
In your functions.php (or in a plugin, or every where else) :
And somewhere in your metabox template (or loaded via an action) :
You'd be surprised at how tricky this one turns out to be. Closest I'm getting is hooking into the
Something more helpful and less stripped down would involve a custom message when the post is published.
This is a quick solution, something even more involved would perhaps require that the saved post which has just infringed the no-duplicate-title rule has to have it's title modified and resaved by the function, turning it into something like 'DUPLICATE! [the title here]' and changing post status back to 'pending'.
The yellow message seems to be quite subtle and may not be noticed by publishers, dying seems to be more attention-grabbing.
Hope this helps and didn't confuse you too much. There may be better solutions to the problem, let's hope someone comes by and helps us improve the solution. Any ideas will be appreciated at this point.
|show 2 more comments|
Instead of making your own query, why not just using the function post_exists() ? It takes the post_title, content and date ( optionnal ). This function does not test the post_type but its rare that you have the same post_title on your content.
find if POST Slug already exists
method 2) (without Mysql query, so it may be a bit slower):