1
votes

Hello I want to Create a home page that has updating blog entries. So 4 lists of headlines from different categories

And I want to have a link to the regular blog page with a different template.

Right now I just changed index.php around to have the containers for the featured posts content.

So this is a two part question how do I get these mini updates for the thing I want to use query_posts() multiple times I assume and separate by category.

And how do I make a linkable page to a blog.php file which currently is telling me that all these functions are undefined.

<?php get_header(); ?>

<?php if ( have_posts() ) : ?>

<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>

    <?php get_template_part( 'content', get_post_format() ); ?>

<?php endwhile; ?>

<?php endif; ?>

<?php get_footer(); ?>
1

1 Answers

1
votes

If you want to create a page that includes WP data/posts outside the themes or blog folder, you need to include and make available the Wordpress functions first:

    define('WP_USE_THEMES', false);
    require('./blog/wp-blog-header.php');

And then you can make the queries for each set of posts by category:

    $args = array( 'numberposts' => '5, 'offset'=> 1, 'category' => 'your category ID' );
    $myposts = get_posts( $args );
    foreach($myposts as $post) {
    ...some code...
    }

I hope it helps.