I have a WordPress loop:
while ( $query->have_posts() ) : $query->the_post();
echo'<h3><a href="index.php?page_id=100">';the_title(); echo'</a></h3>';
echo'<h4>'.the_excerpt().'</h4>
How can I assign post id value to a variable in this loop?
$id = the_id();
don’t work.
You want
get_the_ID()
.All of the functions that start with
the_...
print the value. The functions that start withget_the_...
return the value.