Creating a new .php page that uses template tags
I’m trying to create a separate page called Blog.php that is separate from the main index.php page on a site I’ve created. The front page (index.php) is a 3 column layout, with the two recent blog posts and other stuff in the left and right sidebar (but *no* links to archived entries/etc. in either of those columns – the left is a links column while the right is a “take action on this issue” thing).
The blog.php page is the sort of “blog landing page;” e.g. when a user clicks on the link it will show the most recent blog posts (probably 2 or 3), the same left column from the index.php page, while the right column is going to be different than index.php’s – instead it will have the links to archives by category/date/etc.
I should note here that the left sidebar/column is pulled from sidebar.php while the right column is written directly into the index.php page.
How do I set up a page to do this? I’ve tried duplicating page.php, renamed it blog.php and used
<?php include ___;?>instead of get for the header/sidebar/footer. I then created a new Page using this template, and it comes out fine, except it doesn’t show any of the recent blog posts even though
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
is in there.
I’m a little confused with what you you want to do, but it sounds like you want to have another page that also has the WordPress Loop which lists the most recent posts.
See: http://codex.wordpress.org/The_Loop_In_Action for specific help on that.
Yes, that’s a better way of putting it. 😉 However, when I try to put wordpress specific template tags (such as get_header()) in a new .php page, it doesn’t work.
Download the PHP Exec plugin here.
Be sure to read the usage info!
Or if you want more control over running PHP WITHIN posts, not in general, which I don’t think applies to this situation, but might,
try RunPHP since it covers more PHP commands than PHP Exec, though that one is good, too. I use both.
Dang. It still doesn’t work, even with the phpexec plugin. 🙁
I’m usually not one to bump up my own thread, but I’m getting desperate here… anyone? 🙂
- The topic ‘Creating a new .php page that uses template tags’ is closed to new replies.