0

I'm following a course in WP, fairly new to php but i have some experience with javascript, bootstrap css and html. Currently I'm trying to loop through all the dummy posts that I imported as XML file from https://codex.wordpress.org/Theme_Unit_Test But currenty I'm getting only one "home" page when i view the site. I'm working with these three files: index.php, header.php and footer.php This are the files and the code:

index.php

<?php get_header(); ?>

<?php if(have_posts()) { ?>
    <?php while(have_posts()) { ?>
        <?php the_post(); ?>
        <h2>
            <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title() ?></a>
        </h2>
        <div>
            Posted on 
            <a href="<?php echo get_permalink( ) ?>">
                <time datetime="<?php echo get_the_date('c')?>"><?php echo get_the_date(); ?></time>
            </a>
            By <a href="<?php echo get_author_posts_url( get_the_author_meta( `ID` ) ) ?>"><?php echo get_the_author(); ?></a>
        </div>
    <?php } ?>
<?php } else { ?>
    <p>Sorry, no posts matched your criteria.</p>
<?php } ?>
<?php get_footer(); ?>

footer.php

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

header.php

<!DOCTYPE html>
<html <?php language_attributes(); ?> >
<head>
    <meta charset="<?php bloginfo( `charset` ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <?php wp_head(); ?>
</head>
<body>
2
  • 2
    check that you have set in your dashboard: 'Settings' - 'Reading' - Your homepage displays [] Your latest posts
    – Michael
    Commented Mar 15, 2020 at 17:07
  • Thank you! That solved my problem Commented Mar 16, 2020 at 18:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.