WordPress.org

Ready to get started?Download WordPress

Forums

Creating a new .php page that uses template tags (8 posts)

  1. kc257
    Member
    Posted 8 years ago #

    Hi all-
    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.

    Any suggestions?

  2. Lorelle
    Member
    Posted 8 years ago #

    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.

  3. kc257
    Member
    Posted 8 years ago #

    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.

  4. strawberrie
    Member
    Posted 8 years ago #

    Download the PHP Exec plugin here.

    Be sure to read the usage info!

  5. Lorelle
    Member
    Posted 8 years ago #

    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.

    http://www.nosq.com/2004/10/runphp-wordpress-plugin/

  6. kc257
    Member
    Posted 8 years ago #

    Dang. It still doesn't work, even with the phpexec plugin. :(

  7. kc257
    Member
    Posted 8 years ago #

    I'm usually not one to bump up my own thread, but I'm getting desperate here... anyone? :)

  8. kc257
    Member
    Posted 8 years ago #

    Never mind, fixed it! Just created a duplicate of index.php in the root directory and renamed it blog... can now use all the wordpress template tags in blog.php. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags