Thursday 29 March 2012

Using Wordpress functions outside wordpress.

I am a fan of Codeigniter but I also love Wordpress, recently I read a topic on using wordpress function outside the wordpress i.e. the contents display function which are mostly used within themes can be used in other codeigniter project or even plain php files.
It is quite easy, Here goes the code:


 <?php  
 require( './wp/wp-load.php' );  
 ?>  
<html>
<head>
<title>
   <? echo wp_title('dd'); ?>
</title>
</head>  
<body>  
<h1><?php echo wp_title('dd');?></h1>  
</body>  

You may also use functions like:
 wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );  
to display add a dropdown menu (some css will be required for correct display of menu).