最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Looping through dummy posts and showing them in the main index.php

programmeradmin3浏览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 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>
发布评论

评论列表(0)

  1. 暂无评论