Tag Info

Hot answers tagged


Unless there's a very good (usually performance, or, of course, inability of core functions to do what you need) reason to use raw SQL requests to fetch posts and other data in WordPress, you shouldn't construct your own SQL queries. Instead, you can use WP_Query. In your case, you could fetch the posts like this: $query = new WP_Query( array( ...


You're using a raw SQL query to do a post query, this is bad, because: There are already APIs that do this It is no longer inheriting the default parameters It doesn't go through the caching system so it can be slower Intead, use WP_Query. The reason you're getting trashed posts is because you're not specifying what post status you want. By default ...


The most common way to achieve those features is to implement some sort of interface, usually in JSON or XML. To do this, you either use a plugin (http://wordpress.org/plugins/json-rest-api/ <= Will probably part of core in WP 4.0) or do the AJAX function yourself. An example would be: add_action( 'wp_ajax_get_thumbnail', 'ajax_get_thumbnail' ); ...


You need to escape the quotes in your echo statements: echo "<img src=""; should be changed to: echo "<img src=\""; or you could use single quotes so that you don't have to escape the double-quotes: echo '<img src="'; Similarly, your last line of code should be changed to: echo "\">";

Only top voted, non community-wiki answers of a minimum length are eligible