I have a short question regarding showing information from Wordpress outside of the Wordpress installation: For a project at the company I work, I need a Script that shows up the search result count of a wordpress blog, outside of it. What I mean is a separate website, that is used as a metasearch engine (searches in different blogs), I have to show the search result number from a wordpress blog. There are different approaches that I have in mind. I could maybe use Tip Nr. 8 from this Smashing Magazine Article:
which means creating my own WordPress Loop using The WP_Query Object in a File at the root folder and then inlude this php file in the separate website? or as a second approach I could try and modify this script from the wordpress forum:
so that it pulls, not the the number of posts in the WP database but the search results count. Only I don’t know how to achieve it.
Of course the query:
// ...Formulate the query $query = \" SELECT * FROM `wp_posts` WHERE `post_status` = \'publish\' AND `post_password` = \'\' AND `post_type` = \'post\'\";
// ...Perform the query $result = mysql_query( $query );
// ...Check results of the query and terminate the script if invalid results if ( !$result ) { $message = \'Invalid query.\' . \"n\"; $message .= \'Whole query: \' . $query .\" n\"; die ( $message ); }
// Init a variable for the number of rows of results $num_rows = mysql_num_rows( $result );
// Print the number of posts echo \"$num_rows Posts\";
hast to be different, but I´m really not a php master.
I know i have to you include the wp-load.php in the external files (website outside wordpress) and then it is possible to use all WP-functions, also the Loop. I know also I can search with wp_query when you include that file, but how exactly?
http://www.smashingmagazine.com/2009/06 ... oop-hacks/
which means creating my own WordPress Loop using The WP_Query Object in a File at the root folder and then inlude this php file in the separate website? or as a second approach I could try and modify this script from the wordpress forum:
http://wordpress.org/support/topic/226572?replies=15
so that it pulls, not the the number of posts in the WP database but the search results count. Only I don’t know how to achieve it.
Of course the query:
hast to be different, but I´m really not a php master.
I know i have to you include the wp-load.php in the external files (website outside wordpress) and then it is
possible to use all WP-functions, also the Loop. I know also I can search with
wp_query when you include that file, but how exactly?
Thank you very much for your support! Thanks!