如何从permalink获取帖子id,如“http://localhost/wordpress/animals/cat“在functions.php中,我尝试了url\\u to\\u postid()和get\\u page\\u by\\u path(),但似乎都不起作用。
如何从永久链接中获取帖子ID?
1 个回复
最合适的回答,由SO网友:MikeSchinkel 整理而成
你好@Tirithen:
您是否尝试过(假设您的自定义帖子类型为\'animal\'
而不是\'animals\'
):
$post = get_page_by_path(\'cat\',OBJECT,\'animal\');
结束