[英]How to get post published date from the wp api in the same format of "get_the_date( )" in wordpress
[英]Get published date of Wordpress post from URL
對於體育館網站,我正在為他們提供一個會員區域,用戶可以在其中查看為他們創建的營養計划。
我使用“ the_slug_exists”檢查哪些營養計划可用。
例如。
if (the_slug_exists("nutrition-plan-$userid")) { // show link to nutrition plan 1 }
和
if (the_slug_exists("nutrition-plan-$userid-2")) { // show link to nutrition plan 2 }
這很好用,但是目前,我只能使用通用名稱(營養計划1,營養計划2等)。
有沒有辦法從帖子內部獲取更多信息? 就像它發布時一樣,還是其他字段之一,只是帶有URL。
如果不是這樣,我可以找到另一種方式將這些自定義帖子類型與每個用戶相關聯,從而可以從他們那里訪問帖子數據。
預先感謝您的任何幫助
我知道了...
$thisurl = 'https://evolvefitness.co.uk/nutrition-plans/nutrition-plan-'.$userid;
$npid = url_to_postid($thisurl);
echo get_the_date('d/m/y', $npid);
希望對別人有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.