A (Probably) Simple Problem with The Loop

Okay, I’m very new to WP, but I think I’m starting to get the hang of it. Also, all my issues seem to be very easy to fix.

Here’s the code from my loop.php:

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

<h2><?php the_title(); ?></h2>
<p class="timestamp"><?php the_time('F jS, Y') ?></p>
<p><?php the_content(); ?></p>

<hr />

<?php endwhile; ?>

<div class="navigation">
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries')?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','')?></div>
</div>

<?php else : ?>
	<h2>Not Found</h2>
 	<p>
	<?php _e("Sorry, but you are looking for something that isn't here."); ?></p>

<?php endif;?>

It’s not displaying the post titles or timestamps. Suggestions? Help is always appreciated! :slight_smile:

which file were you editing?

I just upgraded my wp 3 days ago, loop.php is a new file to me. I am trying to figure out what it actually does since all the usual files (index.php, single.php etc) have don’t call loop.php in the theme I am playing with, and all of the files have The Loop in them…

“The Loop” is:


//start loop
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
// stuff like you have
<h2><?php the_title(); ?></h2> 
<p class="timestamp"><?php the_time('F jS, Y') ?></p>
<p><?php the_content(); ?></p> 
// End loop
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>

What pages do you want to change the look of?

Edit: For giggles change

<?php the_time('F jS, Y') ?>

to

<?php the_date('F jS, Y'); ?>

But it is showing the post content? That seems impossible, are you sure this file is actually getting used by your theme?

Lol, I actually fixed all my issues. I made some mistakes with my code (I checked the code I was mimicking again), but it’s all better now :smiley:

Thanks for the help tho!

Soooooooo, should I call my loop file something different? Like maybe there’s a name conflict?

I would say you might not be editing the right loop file.`

Right… but---- rawr. Here’s my code:

index.php

<?php define('WP_USE_THEMES', false); 
      get_header(); ?>
      
        <div id="MainContent">
        	<?php get_template_part('pagecontent', 'loop');?>
        </div>

<?php get_footer(); ?>

loop.php

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

<h2><?php the_title(); ?></h2>
<p class="timestamp"><?php the_time('F jS, Y'); ?></p>
<p><?php the_content(); ?></p>

<hr />

<?php endwhile; ?>

<div class="navigation">
<div class="alignleft"><?php posts_nav_link('','','&laquo; Previous Entries')?></div>
<div class="alignright"><?php posts_nav_link('','Next Entries &raquo;','')?></div>
</div>

<?php else : ?>
	<h2>Not Found</h2>
 	<p><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>

<?php endif;?>

It calls the pagecontent.php file just fine… And I am trying to make my own design (not sure what you meant about the templates :sick: ).

Edit:
I just noticed some typographical/syntax errors… Lemme fix those and see if it does anything.

Edit again:
Nope, did nothing. It was just some spaces (didn’t know if they mattered).

Noticed the missing semicolon, tried it with that, tried it with “date” instead of “time”… didn’t work :sick:

I’m going to look at the WP stuff again.

http://codex.wordpress.org/The_Loop

Oh, and I forgot – I also had some stuff I wanted displayed above the loop (which I added with HTML), but it’s not displaying any of that either.

Okay I figured it out…
The code for The Loop was suppose to be on the index.php file. That’s all. Now I just have to clean it all up.

Thanks for everyone’s assistance tho! Like I said, I’m new to this WordPress stuff! :sick:

If none of the normal templates are using this loop.php file, then editing it won’t change your site. Edit the normal templates and see if the changes are reflected.

Themes can organize their code in completely arbitrary ways. Loop.php has no special meaning to WordPress, it’s not automatically used in any way. It would only be used if that theme was built to require it (either directly with include or with the get_template_part function that is essentially include with the ability for developers to add hooks/filters to this call in the future).

Okay, so I’m not an idiot this time, that’s good :slight_smile:

I called it here:

                <div id="MainContent">
					<?php get_template_part('pagecontent', 'loop');?>

                </div>

But yeah, it’s displaying the content… just not the other stuff… I’ve highlighted to see if it’s just the wrong color or something, but I don’t see it.