我用bootstrap 3创建了一个Wordpress主题,使用以下说明:
http://www.creativewebdesign.ro/en/blog/wordpress/create-a-responsive-wordpress-theme-with-bootstrap-3-header-and-footer/
内容未显示在任何页面上。我不确定容器div:是否有问题
http://www.dawaf.co.uk/creative-mapping/
当我查看页面源代码时,测试文本不会显示。
index.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Wp_Bootstrap
* @since Wp Bootstrap 1.0
*/
// Gets header.php
get_header();
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>
</div><!-- entry -->
<?php endwhile; ?>
<?php endif; ?>
// Gets footer.php
get_footer();
?>
page.php
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Wp_Bootstrap
* @since Wp Bootstrap 1.0
*/
// Gets header.php
get_header();
// Gets footer.php
get_footer();
?>
我在您的代码中看不到<?php the_content(); ?>
。这是显示内容所必需的。在这里,您可以看到有关内容的Wordpress页面。因此,将<?php the_content(); ?>
添加到您的index.php
中,或者更确切地说,添加到您想要显示内容的page.php
文件中。
编辑:
你也可以查看wordpress文件夹中的其他主题(twentyten等)。在那里你可以看到<?php the_content(); ?>
是如何使用的。
编辑2:
我忘了这么说。你也必须将其添加到你的文件中:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>
</div><!-- entry -->
<?php endwhile; ?>
<?php endif; ?>
这将检查你是否有任何帖子或页面。如果是,它将显示它,如果不是,它将不显示任何内容。把这个放到<?php get_header(); ?>
和<?php get_footer(); ?>
之间的index.php
上。
编辑3:
我看到了你对问题的修改。我看到了错误。您打开了<?php
标记两次。你可以走这条路:
<?php
/**
* The main template file.
*
* This is the most generic template file in a WordPress theme and one of the
* two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* For example, it puts together the home page when no home.php file exists.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Wp_Bootstrap
* @since Wp Bootstrap 1.0
*/
// Gets header.php
get_header();
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>
</div><!-- entry -->
<?php endwhile; ?>
<?php endif; ?>
<?php // Gets footer.php
get_footer();
?>
此代码应在您的index.php
和page.php
中。
在page.php中使用此代码:
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_front_page() ) { ?>
<h2 class="entry-title"><?php the_title(); ?></h2>
<?php } else { ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<?php } ?>
<div class="entry-content">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="edit-link">', '</span>' ); ?>
</div><!-- .entry-content -->
</div><!-- #post-## -->
<?php endwhile; ?>