Viktor
Viktor

Reputation: 722

Wordpress post not displaying

header.php - file

I'am new to Wordpress scripting, can't figure out what i've done wrong? My post are not displaying

<nav class="subnav">
    <?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <article>
                <div id="overview" class="tab">
                    <p><?php the_content(); ?></p>
                </div>
            </article>
        <?php endwhile;?>   

    <?php endif; ?>

Upvotes: 0

Views: 43

Answers (3)

Dr.Tricker
Dr.Tricker

Reputation: 553

Header.php

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>

<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
    <header>

        <nav class="subnav">
            <?php wp_nav_menu(array('theme_location' => 'menu')); ?>
        </nav>

            <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <article>
                        <div id="overview" class="tab">
                            <p><?php the_content(); ?></p>
                        </div>
                    </article>
                <?php endwhile;?>   

            <?php endif; ?>

    </header><!-- #masthead -->

    <div id="content" class="site-content">

Output:

enter image description here

Upvotes: 0

mithun raval
mithun raval

Reputation: 180

You can write your code on page.php or post.php otherwise you can create template and put below code and assign page to this template.

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <article>
                <div id="overview" class="tab">
                    <p><?php the_content(); ?></p>
                </div>
            </article>
        <?php endwhile;?> 
    <?php endif; ?> 

Upvotes: 0

Karthik
Karthik

Reputation: 1751

In header.php you should add something like this.

<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<?php wp_head(); ?>
</head>
<nav class="subnav">
    <?php wp_nav_menu(array('theme_location' => 'menu')); ?>
</nav>

In your front-page.php or home.php or index.php** include header.php with a wordpress specific function get_header() then render your menu, posts etc like this:

<?php
get_header();
if (have_posts()) : while (have_posts()) : the_post(); ?>
    <article>
        <div id="overview" class="tab">
            <p><?php the_content(); ?></p>
        </div>
    </article>
    <?php endwhile;?>
<?php endif; ?>

Please refer this

** If you are confused which php file to use please study WordPress hierarchy

Upvotes: 1

Related Questions