• Resolved scorpion380

    (@scorpion380)


    I have a custom fixed PHP/HTML landing page for my site http://harmeet.gabha.net/

    I wish to include here on this (non-wordpress) page things like recent posts (ie. post title) and recent comments. Also maybe a total count of posts.

    Is there a way to call the functions by including specific files in my header? Alternatively, I could connect to each database using my own php code and get this info but I think if there is way to use WordPress functions it would be more cleaner and portable.

    Any help or direction would be appreciated.
    Thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter scorpion380

    (@scorpion380)

    Thanks MichaelH. That’s exactly what I wanted to know. The first link is what I needed.

    Thread Starter scorpion380

    (@scorpion380)

    MichaelH,

    Another question: Is there a trick to querying 3 different wordpress blogs from the same page?

    I have three blogs so need to call three different wp-blog-header.php files. I am doing this in a sequential fashion but the code output results from the first wp-blog-header.php for all three instances.

    Have a look at http://harmeet.gabha.net/indextwo.php. You will see what I mean.

    <div id="heading">My latest <span class="blog">Blogs</span></div>
    	<div id="message">
    	<div id="blogs">
    	<?php require('/home/username/public_html/folder/design/wp-blog-header.php'); ?>
    	<?php
    		$count_posts = wp_count_posts();
    		$published_posts= $count_posts->publish;
    	?>
    	<span>Design Blog<br /><span>(<?php echo $published_posts; ?> posts in 
    
    total)</span></span>
    	<ul>
    	<?php query_posts('showposts=5'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    	<?php endwhile;?>
    	</ul>
    	</div>
    
    	<div id="blogs">
    	<?php require('/home/username/public_html/folder/photography/wp-blog-header.php'); ?>
    	<?php
    		$count_posts = wp_count_posts();
    		$published_posts= $count_posts->publish;
    	?>
    	<span>Photography Blog<br /><span>(<?php echo $published_posts; ?> posts in 
    
    total)</span></span>
    	<ul>
    	<?php query_posts('showposts=5'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    	<?php endwhile;?>
    	</ul>
    	</div>
    
    	<div id="blogs">
    	<?php require('/home/username/public_html/folder/tech/wp-blog-header.php'); ?>
    	<?php
    		$count_posts = wp_count_posts();
    		$published_posts= $count_posts->publish;
    	?>
    	<span>Tech Blog<br /><span>(<?php echo $published_posts; ?> posts in total)
    
    </span></span>
    	<ul>
    	<?php query_posts('showposts=5'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    	<?php endwhile;?>
    	</ul>
    	</div>
    
    	</div>

    Thanks in advance.

    Not sure about that…

    But maybe a plugin such as:
    http://wordpress.org/extend/plugins/feedwordpress/

    Thread Starter scorpion380

    (@scorpion380)

    No problem. I think I can write my own function class to call each blog separately and the return back to my page. Once I get it working I will share the code and post a link.

    Cheers
    Harmeet

    Thread Starter scorpion380

    (@scorpion380)

    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();
    ?>
    Thread Starter scorpion380

    (@scorpion380)

    Is there anybody out there who can help me with this?

    Thread Starter scorpion380

    (@scorpion380)

    FYI.

    To get around this problem I used AJAX to get FEED data from my each site and display it on the page. This way I can call various feeds and display their data on my site.

    Hopefully the next version of WordPress will have this basic capability of calling it’s functions from external php pages. LOL!

    Resolved.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Get Latest Posts for External page’ is closed to new replies.