How to integrate wordpress into joomla 1.5.x

You should install joomla first. Then download wordpress from here.

Now unzip wordpress and put into joomla folder.(e.g. if your joomla site hold joomla folder, then put wordpress inside joomla(joomla/wordpress)).

Now install wordpress  into same database that are already install joomla.

All of the header and footer stuff in WordPress is used from Joomla so you do not need to restyle it in WordPress. All you need to do is to style and work on the content area of the WordPress template output.

Steps:
1) Do the full styling of joomla part. After that, index.php of your joomla template file and surround the header output stuff with comments like:
<!– STARTHeaderContainer –>

—-
——
—-

<!– ENDHeaderContainer –>

2) Do the same for footer output stuff in same file:

<!– STARTFooterContainer –>

—-
——
—-

<!– ENDFooterContainer –>

3) Go to WordPress theme folder, open functions.php file, copy paste the class into it.

class Joomlawordpress_ConnectWJ
{
private $_content;
private $_header;
private $_footer;

public function __construct($url, $markerStartHeader = null, $markerEndHeader = null, $markerStartFooter = null, $markerEndFooter = null)
{
$this->_content = file_get_contents($url);
$this->_renderHeader($markerStartHeader, $markerEndHeader);
$this->_renderFooter($markerStartFooter, $markerEndFooter);
}

public function renderHeader($markerStart = null, $markerEnd = null)
{
return $this->_header;
}

private function _renderHeader($markerStart = null, $markerEnd = null)
{
$markerStart = (is_null($markerStart)) ? ‘<!– STARTHeaderContainer –>’ : (string)$markerStart;
$markerEnd = (is_null($markerEnd)) ? ‘<!– ENDHeaderContainer –>’ : (string)$markerEnd;

$headerStart = stripos($this->_content, $markerStart);
$headerEnd = stripos($this->_content, $markerEnd);

$this->_header = substr($this->_content, $headerStart, $headerEnd-$headerStart);
}

public function renderFooter()
{
return $this->_footer;
}

private function _renderFooter($markerStart = null, $markerEnd = null)
{
$markerStart = (is_null($markerStart)) ? ‘<!– STARTFooterContainer –>’ : (string)$markerStart;
$markerEnd = (is_null($markerEnd)) ? ‘<!– ENDFooterContainer –>’ : (string)$markerEnd;

$footerStart = stripos($this->_content, $markerStart);
$footerEnd = stripos($this->_content, $markerEnd);

$this->_footer = substr($this->_content, $footerStart, $footerEnd-$footerStart);
}

}

4) Inside WordPress theme folder, open header.php and instantiate a class like:

$parts = new Joomlawordpress_ConnectWJ(‘http://example.domain&#8217;);

echo $parts->renderHeader();

5) Inside WordPress theme folder, open footer.php and instantiate a class like:

$parts = new Joomlawordpress_ConnectWJ(‘http://example.domain&#8217;);

echo $parts->renderFooter();
Upon refresh of WordPress home page you should now see the Joomla header and footer loaded with wordpress content.
Now Cool with wordpress and joomla integration.

24 thoughts on “How to integrate wordpress into joomla 1.5.x

  1. Hi

    Thanks for a lovely code. Just need a small help…..

    Can you please reverse the code. I mean can you please help me to get the WordPress Header and Footer into Joomla.

    I tried doing the same process by pasting the code for class into the template.helper file of the Joomla Template and calling the class in the Header and Footer but it did not work. in Joomla however it worked smooth in WordPress.

    Can you kindly help me to get this in Joomla too.

  2. This looks like a useful bit of code, but i can’t get it to work. Which version of joomla or wordpress is it for? I’m using joomla 1.5 and wordpress 3.0

    1. This code is applicable Joomla 1.5 and WordPress 3.0. Please you check carefully, may be something is missing. Please check php.ini file and set “allow_url_fopen = On” .

      1. php.ini file is set “allow_url_fopen = On.

        maybe i’m puting the code in wrong:
        I put: “class Joomlawordpress_ConnectWJ…” at end of functions.php

        how do instantiate the classes for header.php and footer.php?

      2. 4) Inside WordPress theme folder, open header.php and instantiate a class like

        $parts = new Joomlawordpress_ConnectWJ(‘http://example.domain’);

        echo $parts->renderHeader();

        5) Inside WordPress theme folder, open footer.php and instantiate a class like:

        $parts = new Joomlawordpress_ConnectWJ(‘http://example.domain’);
        echo $parts->renderFooter();

  3. am trying to implement this on a remote website. my joomla install is in a sub folder from the root. Header and footer not appearing.does joomla have to be installed in root?

    1. No not necessarily. It works fine even from a remote server too.

      Remember you are calling the output of the remote site here. (this will further slow down your site)

      Check your code for the following:

      1. Make sure you have mentioned the path to your install correctly.

      2. Any left-out semicolons, comas or any such single characters.

      3. Make sure the ClassNames and Markers are the same (case sensitive).

      4. Also make sure that the markers are present in the template of the remote server from where you are trying to pull the data.

      5. Lastly also check the server settings / permissions on both.

      Cheers!

  4. Ok, I understand PHP enough. But I am confused with the instructions. Like where it says “header output stuff”. Where exactly do I paste theses codes.

  5. I have tried this but i only get white screen.

    Could somenone explainme how to do this on a “Mystique” Theme???

    I’m really interested on make it work.

    1. Hi,

      Please check php.ini file “allow_url_fopen=off”, this need to on. If you have no control about this please check curl in on or not. If on then, where file_get_contents($url); is happened you replace the following code

      $c = curl_init();
      curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($c, CURLOPT_URL, $url);
      $this->_content = curl_exec($c);
      curl_close($c)
      Note :Need to curl on in php.ini file.

      Hope this help, if there is something wrong or something you don’t understand let me know 🙂

  6. Thanks for reply.
    “allow_url_fopen” and “curl” are both ON on php.ini

    i´ll try it next week, first i have to upgrade all the cms and plugins 😉

    Best regards.

  7. Hi,
    I tired this code and am getting this error
    Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\james\wordpress\wp-content\themes\twentyten\functions.php on line 508

    Any idea, I’m on a local computer and allow_url_fopen is on

    Thanks

  8. Hi,
    I tired this code and am getting this error
    Parse error: parse error in C:\wamp\www\Joomla_wordpress\wordpress\wp-content\themes\twentyten\functions.php on line 96

    Any idea, I’m on a local computer and allow_url_fopen is on

    Thanks

    1. Hello dear!
      Please you check the code carefully, may be you mistake {},(),comma, etc. Please replace again colon(;), dot(.),single quote(”), double quote(“”).

      Hope you understand!

      If you have any query please let me know.

      Thanks.

  9. Hi there!

    Thanks! header and footer works! but the problem is, joomla contents also shows from header,content down to footer. What i want to be done is that the header and footer will be from joomla and the contents is from wordpress. Please help.

    Thanks!

  10. I am trying to use the code but i get this parse error for this line

    $markerStart = (is_null($markerStart)) ? ‘’ : (string)$markerStart;

    any help

    1. Hi kenneth,

      You should edit spacial character when you paste this code to editor. Like (? ‘’ :).

      If you have any query , let me know.

      Thanks….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s