Jump to content

How to call wordpress header in header.tpl


dick1980

Recommended Posts

Hi,

 

I would like to call the wordpress header in my header.tpl. But several options have left me nowhere... Calling the WP functions has not helped, like this:

 

<?php
include('http://www.evoned.nl/wp-config.php');  
global $wpdb, $table_prefix; 
require( 'http://www.evoned.nl/wp-load.php' );
get_header();
?>

 

And then use the include_php function in the .tpl file. No luck... already 6 hours spent!

 

Any ideas?

Link to comment
Share on other sites

You can't include this way..

<?php include('http://www.evoned.nl/wp-config.php');  ?> 

 

correct way: (use relative path to wp-load.php

<?php
	define('WP_USE_THEMES', false);
	require('../../wp-load.php');
?> 

 

 

---------------------------------------------

Or the other method is to create a getheader.php in the rooth of WP folder. and add the following code.

 

<?php
	define('WP_USE_THEMES', false);
	require('../../wp-load.php');
               get_header();
?> 

 

 

And then add the following code in the header.tpl file under your WHCMS theme folder.

(assumed that you installed WP in the root of the domain)

echo file_get_contents('http://www.yourdomain.com/getheader.php');

[php]

 

 

Hope this helps you. :)

Link to comment
Share on other sites

  • 1 year later...

I have managed to do this once. I'll need to find where i got the info from but i remember it used a cron to run every so often and take the info from the wp header/footer and update the header/footer on whmcs. Or you can just make a static whmcs theme based on your wordpress layout and if you change any of your wp links you'd have to manually change the whmcs theme.

Link to comment
Share on other sites

  • 6 years later...

I took a different approach. 

I created a hook called navigation.php to change the WHMCS menu to have the Wordpress menu items. In my header.tpl I then just modified the style to match my Wordpress style. This is the safest option.  

 

add_hook('ClientAreaNavbars', 1, function ()
{
    // Load Wordpress can get the menu itmes
    require("../jmtech/wp-load.php");
    $wpMenu = wp_get_nav_menu_items('Top Menu');
    
    // Get the current navigation bars.
    $primaryNavbar = Menu::primaryNavbar();
    $secondaryNavbar = Menu::secondaryNavbar();
	
    // Remove unecessary menu items from WHMCS
    $primaryNavbar->removeChild('Announcements');
    $primaryNavbar->removeChild('Knowledgebase');
    $primaryNavbar->removeChild('Network Status');
    $primaryNavbar->removeChild('Home');
    $primaryNavbar->removeChild('Store');
    $primaryNavbar->removeChild('Contact Us');

    // Keep menu in order
    $order = 1;

    // Add a WHMCS menu for each Wordpress menu
    foreach($wpMenu as $item) {
        $primaryNavbar->addChild($item->title)
            ->setUri($item->url)
            ->setOrder($order);
        $order++;
    }
}

 

Link to comment
Share on other sites

  • 2 weeks later...
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated