Search

הצגת הזמן שעבר מאז פורסם הפוסט בוורדפרס

סניפט קטן שנתקלתי בו ב WordPress Codex המאפשר הצגת הזמן שעבר מאז פורסם הפוסט.
הוסיפו את הקוד הבא לקובץ functions.php :


/**
 /**
 * Display time since post was published
 *
 * @uses	human_time_diff()  Return time difference in easy to read format
 * @uses	get_the_time()  Get the time the post was published
 * @uses	current_time()  Get the current time
 *
 * @return	string  Timestamp since post was published
 *
 */
function get_time_since_posted() {

	$time_since_posted = 'לפני ' . human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) );

	return $time_since_posted;

}

לאחר מכן הוסיפו את הפונקציה בתוך הלולאה היכן שתרצו.

echo get_time_since_posted();
מצאתם טעות בקוד? הסניפט לא עובד לכם? רישמו לי בתגובות ואני מבטיח לטפל בכך במהרה ולספק סניפט תקין...
0 תגובות...

תגובה חדשה

Up!
לבלוג