Ok. I started creating a class for what I wanted to do but now I am getting this strange error. Any ideas would be appreciated.
Fatal error: Call to undefined method stdClass::set_prefix() in /home/username/public_html/harmeet/photography/wp-settings.php on line 268
Here is my code. The idea is to create a class and use multiple Objects to initialise. This way using multiple objects I am able to call multiple wp-blog-header.php files and call the necessary functions to do what I want.
I’ve also tried the Full path eg. /home/…./wp-blog-header.php and I get the same error. So I don’t believe its due to this reason.
<?php
class BlogRoll {
public $wp_header_loc;
public function __construct($wp_header_loc = '/wordpress/wp-blog-header.php'){
$this->wp_header_loc = $wp_header_loc;
}
public function GetPostCount(){
include $this->wp_header_loc;
if ($this->wp_header_loc != "")
{
$count_posts = wp_count_posts();
echo $count_posts->publish;
}
}
/*public function GetPostList(){
include($this->wp_header_loc);
if($this->wp_header_loc !="")
{
$data = array();
$i=0;
query_posts('showposts=5');
while (have_posts()) : the_post();
//$data($i) = array('Link'=>the_permalink(),
// 'Title'=>the_title());
endwhile;
return $data;
}
else
{
return NULL;
}
}*/
}
$FirstBlog = new BlogRoll('photography/wp-blog-header.php');
// Tried the Full path eg. /home/.... same error.
//$FirstBlog->wp_header_loc = "/home/username/public_html/harmeet/tech/wp-blog-header.php";
echo $FirstBlog->wp_header_loc;
echo $FirstBlog->GetPostCount();
$SecondBlog = new BlogRoll('design/wp-blog-header.php');
//$SecondBlog->wp_header_loc = "/home/username/public_html/harmeet/design/wp-blog-header.php";
echo "SecondBlog" . $SecondBlog->GetPostCount();
?>