I show my last post in a page with this code:
$query1 = new WP_Query();
$query1->the_post();
and it further with:
$id = $query->ID;
to retrive last post ID
so I wrote a new wp_query and I want to exclue that ID from the results:
I wrote this but it don’t work:
$query2-> new WP_Query('p=-$id');
what’s the problem?
You haven’t excluded anything. Read the Codex.
p=
includes posts. It does not exclude them. What you need ispost__not_in
My code is works fine: