0

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.

2
  • 1
    Are you calling wp_footer() anywhere? And you really should be using wp_enqueue_style instead of pasting in the css includes at the top of the file. Commented Mar 5, 2014 at 19:41
  • thank you for reply, I will use wp_enqueue_style from now. Yes, I'm using a wp_footer() on this page Commented Mar 5, 2014 at 20:57

1 Answer 1

1

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 ?>
Sign up to request clarification or add additional context in comments.

2 Comments

Ok, I've got that. I've tryed to use your snippet and got the same result - only 1 post in loop. How can I get all posts in this case?
just build a second normal wp query with args., and add another loop to display them

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.