0
votes

In my new wordpress theme, i made a static front page and a sub page for blog posts, but the problem is, the posts dont get displayed. If i use it without the static front page the posts display normally. What could be wrong?

Here is my code for the blog page:

<?php 

/*  
Template Name: Blog page    
*/

get_header();
?>

<!--parallax section 1-->
<div class="section-one">
    <div class="parallax-section-1">
    </div>
    <div class="container-fluid">
        <h1>News</h1>
    </div>
</div>

<div class="container-fluid">

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

            <div class="post">
                <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                <h6>Posted on <?php the_time('F jS, Y'); ?> by <?php the_author_posts_link(); ?></h6>

                <div class ="entry">
                    <?php the_content(); ?>
                </div>
            </div>

        <?php
            endwhile;
            else: 
        ?>
            <p> Sorry, no posts to display.</p>
        <?php endif; ?>

</div>

<?php get_footer(); ?>
1
Did you set the page as the Posts Page under Settings > Reading? - Peter
yes, i did. The page is shown, everything except posts - mheonyae
Try removing the if and just have the while. So it should start with <?php while ( have_posts() ) : the_post(); ?> and end with <?php endwhile; ?> - Peter

1 Answers

0
votes

insert before "if"

$args=array(
     'post_status' => 'publish',
     'posts_per_page' => 4,
     'order' => 'ASC'
                );
$my_query = new WP_Query($args);