开发者

I can't modify the template i assigned to the Posts page (Wordpress)

开发者 https://www.devze.com 2023-01-13 22:34 出处:网络
I created 2 files: home.php and blog.php. The first one is set to be my Front Page and the later to be the Posts page. When I modify home.php I can see the chang开发者_StackOverflowes (for instance de

I created 2 files: home.php and blog.php. The first one is set to be my Front Page and the later to be the Posts page. When I modify home.php I can see the chang开发者_StackOverflowes (for instance deleting the sidebar). But when I try to modify blog.php nothing happens.

Do I have to modify other .php file in order to see changes in the Blog (Posts page) page?

home.php

<?php
/*
Template Name: Home
*/

get_header(); ?>

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

     <?php if ( is_front_page() ) { ?>
      <h2><?php the_title(); ?></h2>
     <?php } else { ?>
      <h1><?php the_title(); ?></h1>
     <?php } ?>

      <?php the_content(); ?>
      <?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
      <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>

    <?php comments_template( '', true ); ?>

<?php endwhile; ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

blog.php:

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

     <?php if ( is_front_page() ) { ?>
      <h2><?php the_title(); ?></h2>
     <?php } else { ?>
      <h1><?php the_title(); ?></h1>
     <?php } ?>

      <?php the_content(); ?>
      <?php wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyten' ), 'after' => '' ) ); ?>
      <?php edit_post_link( __( 'Edit', 'twentyten' ), '', '' ); ?>

    <?php comments_template( '', true ); ?>

<?php endwhile; ?>

<?php get_sidebar(); ?>
<?php get_footer(); ?>


Here are a coupple of links that I think will help you:

http://codex.wordpress.org/WordPress_Lessons#Customizing_Templates
http://codex.wordpress.org/Template_Hierarchy

I have a few questions:

  1. Why do you have the same code in both tempaltes? Frontpage will never be the same as a single post.
  2. Why do you choose to use blog.php instead of single.php? When you open a Post, WP will automatically use single.php.
  3. Have you sett in settings which page should be the front page?
  4. If you are creating a template, then you must have template name at the top of the file (missing in blog.php)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号