[wp-hackers] "deprecating" direct calls to wp-config.php

Ken Newman Ken at adcSTUDIO.com
Tue Nov 3 20:24:06 UTC 2009


On 11/3/2009 3:08 PM, Claudio Simeone wrote:
> Thank you all for your answers. Maybe I didn't explain well myself,
> and I apologize for this :)
> When I need to extend my WP, I do that in the clean way, writing
> plugins, using built-in hooks and filters, the correct ajax calls, and
> everything goes all right.
> So my question was more related to a scenario in which I need to
> "import" all WP functions, into another - external - script, that is
> not directly connected with my WP installation, or it is not inside my
> installation.
>
> Let's say I have another CMS and I want to retrieve some info from the
> database (making a sort of integration), for example the last 3 posts
> (I know that I can get these informations via the RSS Feed, but this
> is only an example), it's very easy to me to create a ph script
> 'last_posts.php' and make something like:
>
> <?php
> include_once('wordpress/wp-load.php'); // or wherever it is
> $lastposts = get_posts('numberposts=3');
> foreach($lastposts as $post) :
>      setup_postdata($post);
> ?>
> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
> <?php endforeach; ?>
>
> with this trick I can use the Loop in an external file, and very
> important, I can use all WP functions, instead to reinvent the wheel
> using php mysql functions and "classic" code, and writing new
> functions from scratch for example to get the post permalinks.
> I know that is as Otto says, sloppy, but it's my way to "use" WP
> system in external scripts.
> So I asked if this is a wrong way of using WP and if there is a right
> way to achieve the same result.
>
> thanks again
> Claudio
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>    
For integrating php apps with WordPress, you could use what is suggested 
on bbpress.og [ 
http://bbpress.org/documentation/integration-with-wordpress/ ] which is 
|require_once('path/to/wp-blog-header.php');| in your app. Hope this helps.


More information about the wp-hackers mailing list