I post content via wp_insert_post() but i need to check if the title already posted.
Also what is the function to convert title "Hannah Teter Sports Illustrated" to "hannah-teter-sports-illustrated" ?
Please help
I post content via wp_insert_post() but i need to check if the title already posted.
Also what is the function to convert title "Hannah Teter Sports Illustrated" to "hannah-teter-sports-illustrated" ?
Please help
// check if title $my_post_name already exists in wpdb
global $wpdb;
if($wpdb->get_row("SELECT post_title FROM wp_posts WHERE post_title = '" . $my_post_name . "'", 'ARRAY_A')) {
echo $my_post_name.' already exists'; }
google came up with this article about post slugs:
http://www.bernzilla.com/item.php?id=1007
http://codex.wordpress.org/Function_Reference/sanitize_title_with_dashes
(wp2.9: around line 770 in wp-includes/formatting.php)
Thanks alchymyth. It works...
it doesn't work in wp2.9.2
why ?
This topic has been closed to new replies.