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:

define('WP_USE_THEMES', false);

<?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')"

Need Your Help

Strange Git line ending issue

git text github newline

I'm working with a few other people editing some CSV files collaboratively which are stored in a repository on Github. We have collaborators using Windows, OS X, and Linux, so to deal with differen...

Why is async causing issues in my javascript?

asynchronous knockout.js

Can anyone tell me why async: false; doesn't allow my spinner to display during data load?