Libre
Libre

Reputation: 3

Wordpress recent posts not showing on homepage, but shows up on other pages

Pulling the 3 latest posts from a custom post type on my footer.php, but the FAQ list isn't appearing on my homepage, it appears on the other pages though, using the same footer.php file.
Homepage: http://tinyurl.com/p922sc8

enter image description here


Other pages: http://tinyurl.com/ond88ll & http://tinyurl.com/pd5qndd

enter image description here


Here's my loop:

<?php  if (have_posts()) : ?>
    <?php query_posts('post_type=faq&posts_per_page=3&order=ASC'); while ( have_posts() ) : the_post(); ?>
        <li><a href="<?php echo home_url() . "/faq"; ?>#answer<?php the_id() ?>"><?php the_title(); ?></a></li>
    <?php endwhile;?>
<?php endif; ?>
<?php wp_reset_query(); ?>


Any idea why?

Upvotes: 0

Views: 175

Answers (1)

Hamid Mohayeji
Hamid Mohayeji

Reputation: 4275

First of all, query_posts is deprecated. Use WP_Query instead. Remember you should first determine your query, and then use the loop.

<?php $q = new WP_Query(array('post_type' => 'faq', 'posts_per_page' => '3', 'orderBy' => 'title', 'order' => 'ASC')) ?>
<?php if($q->have_posts()): while($q->have_posts()) : $q->the_post(); ?>
    <li><a href="<?php echo home_url("/faq"); ?>#answer<?php the_id() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>

Upvotes: 1

Related Questions