Skip to content

Instantly share code, notes, and snippets.

@generatepress
Created July 27, 2014 06:55
Show Gist options
  • Save generatepress/5e35a595e01380e269f0 to your computer and use it in GitHub Desktop.
Save generatepress/5e35a595e01380e269f0 to your computer and use it in GitHub Desktop.
require_once( '../../wp-load.php' );
$args = array(
'post_type' => 'edd_license',
'showposts' => -1,
's' => $_POST['email']
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
$posts = $the_query->get_posts();
$items = array();
foreach ( $posts as $post ) {
$item_name = $post->post_title;
$items[] = substr( $item_name, 0, strrpos($item_name,' -') );
}
echo json_encode($items);
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment