have_posts() not working
-
Hi,
I’ve upgraded my site to version 4.0 and trying to add the code snippet below on 2 pages on a new website I’ve just started but it only works on one of the pages, returning the latest 10 posts. On the second page, I wanted only the latest 3 posts, but have_posts() function seem to return false and not going into the if statement – yet there are posts in the blog.
if ( have_posts() ) :
// get the latest 10 …
$posts = get_posts(‘numberposts=10&order=DESC&orderby=post_date’);
endif;I’ve tried rewind_posts() and wp_reset_postdata() functions after each call and it hasn’t worked either. I’ve searched through the posts and found some references to permalinks but I wasn’t using permalinks so unsure what the problem is (I tried using permalinks and that doesn’t work either).
Why is the same code only working on one page? Does anyone have a clue, please? I’ve got this at the top of both pages:
<?php
/* include wordpress blog contents */
define(‘WP_USE_THEMES’, false);
require(“/path/to/wp-blog-header.php”);
?>The blog site is here: https://www.totalpersoninu.co.uk/ but I’m trying to display the posts on these pages: https://www.balancewellness.co.uk/zNEWsite/index.php and https://www.balancewellness.co.uk/zNEWsite/blog/index.php. It works fine on the latter but not on the former – the posts should be displayed under the section titled “Latest information / events”.
Thanks for your help.
Dantina
- The topic ‘have_posts() not working’ is closed to new replies.