我想你不是在寻找当前的帖子/页面ID,而是在试图从你的网站上找到某个url的ID。
那你应该试试手边的url_to_postid()
WordPress核心功能。
如果存在,则返回帖子/页面ID,否则返回0
.
Example:
echo url_to_postid( \'http://example.com/2014/11/14/hello-world\' );
// Outputs the post ID as 1 in this example.
Update:
<回复评论:您可以创建一个自定义字段,名为。
url_offer
, 从后端

和使用:
$url_offer = get_post_meta( get_the_ID() , \'url_offer\', true );
在前端检索它。