Get the Title of all posts
Im using Wordpress, Im also creating posts via XMLRPC based on an RSS feed that is added to periodically.
What I want is to read all post titles, compare those against the RSS feed, then only post to Wordpress where the post titles dont exist.
I'm trying this code:
<?php define('WP_USE_THEMES', false); require('../wp-load.php'); query_posts('showposts=-1&author=1&post_status=publish'); ?> <?php while (have_posts()): the_post(); ?> <?php the_title(); ?> <?php endwhile; ?>
This gets all titles from published posts, I then need to do the same to get the draft posts.
I need to write these title's to an array?
It will be more efficient to write your own query to retrieve just the post titles rather than using query_posts. Something like this should work:
$titles = $wpdb->get_col( "SELECT post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_author = 1 AND post_status IN ('publish', 'draft')" );