Reputation: 2117
I've created custom template and added page using this template. But Loop does not working correctly there: Loop returns article with page id (which doesnt exists obviously). Can anyone give an advice about that?
Header.php I used in my custom template (Loop works correct on index.php with this header):
<head>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/css/styles.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/css/ptsans.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/css/ptserif.css" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_directory'); ?>/css/neucha.css" />
<script type="text/javascript"></script>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width" />
<title><?php wp_title(''); ?><?php if( wp_title('', false) ) { echo ' |'; } ?> <?php bloginfo('name'); ?></title>
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
Loop is basic too:
<?php while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-conten clr">
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links clr">', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
</div><!-- .entry-content -->
<footer class="entry-footer">
<?php edit_post_link( __( 'Edit Page', 'wpex' ), '<span class="edit-link">', '</span>' ); ?>
</footer><!-- .entry-footer -->
</article><!-- #post -->
<?php comments_template(); ?>
<?php endwhile; ?>
Hope someone can explain what I'm doing wrong.
Upvotes: 0
Views: 257
Reputation: 1554
nothing wrong. Page technically is a post (check the_ID() in dashboard), with different template. In fact you can use the same code. Maybe just tag is not best idea for pages. to test try simplest loop
<?php while ( have_posts() ) : the_post(); the_content(); endwhile; // THE LOOP ?>
Upvotes: 1