WordPress.org

Ready to get started?Download WordPress

Forums

Loop not working correctly (7 posts)

  1. redbird5
    Member
    Posted 1 year ago #

    I have been making a WordPress from scratch, this the first time for making one. Unfortunately I've been stuck for a week on trying to get the Main Index Template to work with the loop. This is the loop

    <?php get_header(); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <?php endwhile; else: ?>
    	<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    
    <?php get_footer(); ?>

    This is the home page. What is going on here and why isn't it working. I would like to understand how this works. I can read PHP and have a fair understanding of it, but I just don't know what's going.

    <div id="content">
    <div id="slideshow" class="grid_8">Slideshow?</div><!--end slideshow--> <!--Note to self put slideshow index page-->
    
    <div class="news">
    <h1 class="news">Upcoming Events</h1>
    <!--<h1 class="news">Upcoming Events</h1>-->
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacinia leo non ipsum dapibus, mattis viverra est blandit. Aenean quis mi eu lorem sollicitudin aliquet ut sed leo. Aliquam quis nibh molestie, scelerisque magna at, auctor nunc. Aliquam rhoncus interdum fermentum. Praesent blandit, lacus et ornare tristique, purus dui pellentesque lacus, non aliquam leo nisi et quam. Praesent cursus elit sed libero dignissim posuere. In sed arcu ac libero consequat convallis ut suscipit felis. Ut sollicitudin purus auctor, dignissim magna ut, ultrices augue. Nam scelerisque porta tempor. Nullam nulla justo, posuere id nisl at, elementum eleifend sem. Phasellus pretium consectetur sem, in dapibus elit viverra vel.</p>
     <div class="btn">Contact Button</div>
    </div><!--end news-->
    <div class="news">
    <h1 class="news">Featured Animal</h1>
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer lacinia leo non ipsum dapibus, mattis viverra est blandit. Aenean quis mi eu lorem sollicitudin aliquet ut sed leo. Aliquam quis nibh molestie, scelerisque magna at, auctor nunc. Aliquam rhoncus interdum fermentum. Praesent blandit, lacus et ornare tristique, purus dui pellentesque lacus, non aliquam leo nisi et quam. Praesent cursus elit sed libero dignissim posuere. In sed arcu ac libero consequat convallis ut suscipit felis. Ut sollicitudin purus auctor, dignissim magna ut, ultrices augue. Nam scelerisque porta tempor. Nullam nulla justo, posuere id nisl at, elementum eleifend sem. Phasellus pretium consectetur sem, in dapibus elit viverra vel.</p>
     <div class="btn">Contact Button</div>
    </div><!--end news-->
    </div>
  2. Seylin
    Member
    Posted 1 year ago #

    Does your server have a log file? Do you see any errors in there? You may want to google WP DEBUG and turn that on in your wp-config.php file.

  3. redbird5
    Member
    Posted 1 year ago #

    I don't see errors. I need an extra set of eyes whose more experienced in WP than I am to see if there are any errors.

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

  4. ronangelo
    Member
    Posted 1 year ago #

    What do you mean not working correctly? What are you expecting to happen?
    Do you mean no posts are appearing?

    Some things are missing. There's nothing in between this two codes

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

    and this

    <?php endwhile; else: ?>

    There should be something to indicate how the posts would appear
    You can see my example here http://ronangelo.com/create-a-wordpress-theme-beginners-guide/

  5. redbird5
    Member
    Posted 1 year ago #

    This is meant to be a home page. So the only thing that should show up is the contents for that page. Have I not put in the right code just yet to make everything work?

  6. redbird5
    Member
    Posted 1 year ago #

    What I'm looking to see happen is that the content shows up.
    This the the tutorial I'm using to create my theme.

  7. redbird5
    Member
    Posted 1 year ago #

    I got it working. Some of the divs are sitting on top of each other, but it's doing what it should be doing.

Topic Closed

This topic has been closed to new replies.

About this Topic