Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jorge Rafael Garcia
PLUS
Jorge Rafael Garcia
Courses Plus Student 2,633 Points

empty <p> tags

I'm creating my own wordpress theme, I've added the Header and the footer and the Loop. When I go to inspector in Chrome I see there are some empty p tags that I didn't create. Why is this? How can I avoid it?

I have the following code:

index.php:

<?php get_header(); ?>


<section class="row">
  <div>

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

    <h1><?php the_title(); ?></h1>
    <p><?php the_content(); ?></p>

  <?php endwhile; else : ?>

    <p><?php _e("Sorry, no posts found"); ?>

  <?php endif; ?>

  </div>
</section>

<?php get_footer(); ?>

header.php:

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title><?php wp_title(); ?></title>
  <?php wp_head(); ?>
</head>
<body>
  <header>
    <h1><?php echo bloginfo('name') ?></h1>

  </header>

footer.php:

<footer>
  <p>Copyright <?php echo date('Y'); ?></p>
</footer>

<?php wp_footer(); ?>
</body>
</html>

functions.php:

<?php

add_theme_support( 'menus');

function register_theme_menus() {
    register_nav_menus( array('primary-menu' => __('Primary Menu')));
}
add_action('init', 'register_theme_menus');

function etc_theme_styles(){
  wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
}

add_action( 'wp_enqueue_scripts', 'etc_theme_styles' );

function etc_theme_js() {

  wp_enqueue_script( 'main_js', get_template_directory_uri() . '/js/main.js' , array('jquery'), '', true);
}

add_action( 'wp_enqueue_scripts', 'etc_theme_js');

 ?>

Hi Jorge,

Could you post your code so we can take a look please?

Thanks

-Rich

1 Answer

Sue Dough
Sue Dough
35,800 Points

Could the empty p tags be because no content?