How would I limit this query so it only gives me one result?
Code:
function next_prodn_header() {
$StartDate = get('start_date');
$timestamp = strtotime($StartDate);
$EndDate = get('end_date');
$Now = strtotime(date('d开发者_StackOverflow社区-m-Y'));
$Start = strtotime($EndDate);
$newStart = date_i18n('d-m-Y', $Start);
if ($Now <= $Start) {
for ($i = 1; $i < 1; $i++) {
echo "<h2>Next Event</h2>";
echo "<span class=\"month\">";
echo date_i18n('M', $timestamp);
echo "</span>\n";
echo "<span class=\"year\">";
echo date_i18n('Y', $timestamp);
echo "</span>\n\t\t";
echo "<p><a href='";
echo the_permalink();
echo "' title='";
echo the_title();
echo "'>";
echo the_title();
echo "</a></p>\n\t\t";
}
} else {
echo "";
}
}
If by query you meant your for
loop, start the loop at $i = 0
. As of right now, your for-loop structure checks if 1 < 1
which evaluates to false, so it doesn't run the code inside of the loop.
Otherwise, I am not exactly sure what your question is regarding.
精彩评论