WordPress.org

Ready to get started?Download WordPress

Forums

Create a Page Template - not displaying correctly (2 posts)

  1. MrCod
    Member
    Posted 4 years ago #

    Hello,

    I am trying to create a Page Template called Blog.php so whenever I create a page and use this template it will display all my blog titles. The problem is that it's not displaying what i want. The the_title() is displaying the name of the page and not the title of the blogs. The the_peralink() is just displaying the page link (ie url.com/blog) and not the link of the actual blogs.

    <?php
    /*
    Template Name: Blogs
    */
    ?>

    <?php get_header(); ?>

    <!-- CONTENT -->

    <div id="content">

    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>

    <?php the_title() ?>
    <?php the_permalink() ?>
    <?php the_excerpt(); ?>

    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>

    </div>

    <?php get_sidebar(); ?>

    <!-- /CONTENT -->

    <?php get_footer(); ?>

  2. alchymyth
    The Sweeper & Moderator
    Posted 4 years ago #

    general
    http://codex.wordpress.org/Pages
    more specific
    http://codex.wordpress.org/Pages#Page_Templates
    as a guideline
    http://codex.wordpress.org/Pages#A_Page_of_Posts
    how to define what to show
    http://codex.wordpress.org/Function_Reference/query_posts

    you need to add a line with query_posts() before 'if(have_posts())'

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.