Tom
Tom

Reputation: 11

Zend Framework and Wordpress integration

Here is my problem:

I have require_once '../application/bootstrap.php'; in my index.php in root folder for zf website. and i have wordpress blog into public_html/blog.

I need to show wordpress post into zf website or use all wordpress data using wordpress function within zf website.

I read this post [ Last part ] but confused what to add into zend/wordpress folder. Zend Framework and Wordpress Integration

within my bootstrap.php file, i have include path to /library '../application/default' etc and initializing and run of controller.

How do I call wordpress wp_get_post for e.g within my ZF code?

i don't need redirect but use wordpress content within ZF website

Upvotes: 1

Views: 2481

Answers (3)

awavi
awavi

Reputation: 847

To access any zend framework function from your wp page you can use this code:

     <?php
        // get zend framework components
        require_once 'Zend/Loader/Autoloader.php';
        Zend_Loader_Autoloader::getInstance();

        // add your ZF code below this line
        $your_zf_code = new Zend...;
        echo $your_zf_code->getBaseUrl();

      ?>

Just make sure you are your zf's library folder in the include path.

Upvotes: 0

jonathancardoso
jonathancardoso

Reputation: 12707

To access the functions of wordpress from any file you just need to insert the following piece of code into your current file:

<?php 
/* This make the magic: */
define('WP_USE_THEMES', false);
require('path-to-the-file/wp-blog-header.php');

/* This retrieve the last 3 posts */
query_posts('showposts=3');
while (have_posts()) : the_post();
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a><br />
<?php endwhile;?>

Cheers.

Upvotes: 2

chrisweb
chrisweb

Reputation: 1510

Perhaps the easiest way is to use wordpress db structure but not it's code. You could use zend frameworks models to retrieve the pages from wordpress database and show them using zend frameworks controller actions.

If you want to use wp_get_post in your zend framework app you will have to find where the wordpress function resides and then include that file into zend framework.

Upvotes: 1

Related Questions