Reputation: 1411
i know in wordpress loop
the_ID();
will output the post id, if i want to set $var = the post id; what should i do?
Upvotes: 0
Views: 716
Reputation: 25435
Instead of the_ID(), which echoes its result, use the function get_the_ID(), which returns the ID and you can assing it to a variable to be used in your php script.
$postid = get_the_ID();
/* do here what you need with $postid.. */
FYI, there's a nice official repository of WP APIs, the CODEX
Upvotes: 1