Do you notice any different on my home page? Yes.
It is not longer very static informations. It does have a brief introduction. Of course, that is static. Then there are two parts that are dynamic information. The first one is the recent posts of my blog. The second one is some random images from my gallery. How these can be done? You can refer to the references below. The final home page template is shown as below.
<?php
/**
* @package WordPress
* @subpackage Your_Theme
*/
/*
Template Name: Home
*/
get_header(); ?>
<div id="container">
<div id="content">
<div class="entry-title">
<h2>Welcome</h2>
</div><!-- .entry-title -->
<div class="entry-content">
<p>This place for sharing the things that I know. Hope you guys like it.</p>
</div><!-- .entry-content -->
<div class="entry-title">
<h2><a href="./blog/" title="Blog">Blog</a>: What's Fresh</h2>
</div><!-- .entry-title -->
<div class="entry-content">
<ul>
<?php
$how_many=8; //How many posts do you want to show
$news=$wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts
WHERE `post_type`=\"post\" AND `post_status`= \"publish\" ORDER BY
`post_date` DESC LIMIT $how_many");
foreach($news as $np){
printf ("<li><a href=\"index.php?p=%s\">%s</a></li>",
$np->ID,$np->post_title);
}
?>
</ul>
</div><!-- .entry-content -->
<?php
$number_of_pic=18;
$Width=60;
$Height=60;
if (function_exists("nggDisplayRandomImages")) {
?>
<div class="entry-title">
<h2><a href="./gallery/" title="Gallery">Gallery</a>: Random Images</h2>
</div><!-- .entry-title -->
<?php
nggDisplayRandomImages($number_of_pic,$Width,$Height);
}
?>
</div><!-- #content -->
</div><!-- #container -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
References
Comments
Comments powered by Disqus