how to write Blog.php template?
-
hi there, my blog is a part of my website. When I click into the Blog page, how to show all post there? I made a Blog.php as a template, but it doesn’t work. How can I fix the problem? Thanks.
-
what is in your page template?
did you follow the instructions in the codex: http://codex.wordpress.org/Pages#Page_Templates?
do you have a page (with the title ‘Blog’) that is using the Blog.php template?yes, I have a page with the title “Blog” that is using the Blog.php template. The blog.php is based on index.php. The code is here:
<?php
/*
Template Name: Blog
*/
?><?php get_header(); ?>
<div id=”rightcol”>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class=”post”>
<div class=”bigform”>
<div class=”smallform”>
<h5 class=”articletitle”>” title=”Permalink to <?php the_title(); ?>”><?php the_title(); ?></h5>
<span class=”post-meta”><?php the_time(‘F j, Y’); ?> | filed
under <?php the_category(‘, ‘) ?> | <?php comments_popup_link(‘0 Comments’, ‘1 Comment’, ‘% Comments’); ?></span><?php the_content(‘ ‘); ?>
</div>
<div id=”readmore”>
<span class=”post-footer”>” title=”Continue Reading <?php the_title(); ?>”>READ MORE TOP</span>
</div></div>
<div class=”formbg”>
</div></div>
<?php endwhile; ?>
<div class=”navigation”>
<div class=”alignleft”><?php next_posts_link(‘« Older Entries’) ?></div>
<div class=”alignright”><?php previous_posts_link(‘Newer Entries »’) ?></div>
</div>
<?php else : ?>
<h2>Not Found</h2>
<p class=”center”>Sorry, but you are looking for something that isn’t here.</p>
<?php include (TEMPLATEPATH . “/searchform.php”); ?>
<?php endif; ?>
</div><div id=”leftcol”>
<?php get_sidebar(); ?>
</div><div id=”contentbg”>
</div>
<?php get_footer(); ?>But the page display like this: http://raincao.com/diaries/
How to show all my post in this page?
you could change the settings in ‘admin’ ‘settings’ ‘reading’ -> blog pages shown at most: -1 (that should show all posts in the page).
or edit Blog.php and add the line with query_posts():
<div id="rightcol"> <?php query_posts($query_string . '&posts_per_page=-1'); ?> <?php if (have_posts()) : ?>yes, I tried this, but it doesn’t work. The Blog page still display like this: http://raincao.com/diaries/
I tried to change the “Setting” > “reading”, but it still doesn’t work. I have no idea what the problem is.
hi, I think the Blog page works fine now. I changed the page template to default, then it returns to normal.
But now the problme is when I add the Home.php for my font page, the blog page meets trouble again. Do you know how to write Home.php in right way? Thanks.
Here is my code:
<?php /* Template Name: Home */ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta name="author" content="Rain Cao" /> <meta name="keywords" content="rain, graphic design, visual" /> <title>rain-home</title> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" /> </head> <body id="rain_main_website"> <div id="container_home"> <div id="header_home"> <a href="home.php"><img src="<?php bloginfo('template_directory'); ?>/images/top_logo.jpg" border="0"/></a> </div> <div id="content_home"> <div id="quicksummary"> <h1 class="welcome">Welcome.</h1> <p class="quicksummary_home">Hello, my name is <span class="hightlight">Rain Cao</span>. I am a graphic & web designer. On this website you will find my design works in my <a href="rain_portfolio.html">Online Portfolio</a>, and you can also click “<a href="rain_about.html">about</a> or my "<a href="rain_diaries.html">diaries</a>" to know more information about me. Thanks for visiting my site.</p> </div> <div id="menu"> <li class="menu_home"><a href="http://localhost/wordpress/about/">About Rain</a></li> <li class="menu_home"><a href="http://localhost/wordpress/portfolio/">Portfolio</a></li> <li class="menu_home"><a href="http://localhost/wordpress/diaries/">Diaries</a></li> </div> <div id="contact"> <div id="contact_home"> <div id="txt"> Send me email:<br /> <span class="link"><a href="#">raincao@ymail.com</a></span> </div> </div> </div> </div> <div id="footer_home"> <div id="copyright"> (c) copyright designed by rain cao 2009 </div> <div id="menu"> site map | powered by word press </div> </div> </div> </body> </html>
The topic ‘how to write Blog.php template?’ is closed to new replies.