WordPress.org

Ready to get started?Download WordPress

Forums

Loop isn't working (5 posts)

  1. chopsky
    Member
    Posted 1 year ago #

    Anyone have any idea why this loop isn't working? Nothing displays and I already have several posts:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_content(); wp_link_pages(); ?>
    <?php endwhile; endif; ?>

    Thanks!

  2. KaugKo
    Member
    Posted 1 year ago #

    which php file do you placed the code?

  3. chopsky
    Member
    Posted 1 year ago #

    it's in page.php

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    you might need to add a query before the code;

    if this is your secondary loop in page.php then probably better use WP_Query() - http://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts?rq=1

    what is the full code of page.php right now?
    and what exactly are you trying to achieve?

  5. chopsky
    Member
    Posted 1 year ago #

    I have created a "Blog" page which I have set to be a static page for the Front page to display. I have set the Blog page to the Default Template, which I believe is page.php. I simply want my site's home page to be the blog.

    The code is as below:

    <?php get_header(); ?>
    
    <?php if (function_exists('dynamic_sidebar') && is_page() && is_active_sidebar('page-sidebar')): ?>
    <div class="siteColumnLeft clearfix">
    <?php endif; ?>
    
    <div class="separator"></div>
    
    <!-- Content -->
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_content(); wp_link_pages(); ?>
    <?php endwhile; endif; ?>
    
    <?php if (function_exists('dynamic_sidebar') && is_page() && is_active_sidebar('page-sidebar')): ?>
    </div>
    <?php endif; ?>
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    [No bumping. If it's that urgent, consider hiring someone.]

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.