Check my code, please?
-
Hi,
I (no programmer!) am doing my first WP site and wondered if someone could check the code of these three templates for any obvious mistakes.
The site is more of a “traditional” website managed with WP than a blogging site, as such.
1: index.php – used in conjunction with a plugin to make a single post my home page.
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(''); ?>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php endif; ?>2: category.php – prints a list of articles within the current category:
<h2><?php single_cat_title(); ?></h2>
<p>
<?php echo(category_description(the_category_ID(false))); ?>
</p>
<ul>
<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><br/>
<?php the_excerpt(); ?>
</li>
<?php endforeach; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?></ul>3: single.php – when someone clicks on any post this is the template:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>Thank you!
- The topic ‘Check my code, please?’ is closed to new replies.