Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
WordPress Theme Development

index.php in WordPress Themes

Build the fallback template that WordPress uses when no more specific template matches.

index.php in WordPress Themes — a practical guide to WordPress index.php theme with clear examples you can reuse in real projects.

WordPress Theme Development Series (10/96). Prefer one article? Read the complete WordPress theme development tutorial.

Short description

`index.php` is mandatory for classic themes and is the last fallback in the template hierarchy.

Basic index.php

<?php get_header(); ?>
<main>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  <article <?php post_class(); ?>>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
  </article>
<?php endwhile; else : ?>
  <p><?php esc_html_e('No posts found.', 'acme-theme'); ?></p>
<?php endif; ?>
</main>
<?php get_footer(); ?>

Leave a reply

Your email address will not be published. Required fields are marked *