返回介绍

url_to_postid()

发布于 2017-09-11 11:10:00 字数 3038 浏览 1205 评论 0 收藏 0

url_to_postid( string $url )

Examine a URL and try to determine the post ID it represents.


description

Checks are supposedly from the hosted site blog.


参数

$url

(string) (Required) Permalink to check.


返回值

(int) Post ID, or 0 on failure.


源代码

File: wp-includes/rewrite.php

function url_to_postid( $url ) {
	global $wp_rewrite;

	/**
	 * Filters the URL to derive the post ID from.
	 *
	 * @since 2.2.0
	 *
	 * @param string $url The URL to derive the post ID from.
	 */
	$url = apply_filters( 'url_to_postid', $url );

	// First, check to see if there is a 'p=N' or 'page_id=N' to match against
	if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) )	{
		$id = absint($values[2]);
		if ( $id )
			return $id;
	}

	// Get rid of the

更新日志

Versiondescription
1.0.0Introduced.

相关函数

Uses

  • wp-includes/rewrite.php: wp_resolve_numeric_slug_conflicts()
  • wp-includes/formatting.php: trailingslashit()
  • wp-includes/class-wp-matchesmapregex.php: WP_MatchesMapRegex::apply()
  • wp-includes/class-wp-query.php: WP_Query::__construct()
  • wp-includes/functions.php: absint()
  • wp-includes/link-template.php: set_url_scheme()
  • wp-includes/link-template.php: home_url()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/option.php: get_option()
  • wp-includes/post.php: get_page_by_path()
  • wp-includes/post.php: get_post()
  • wp-includes/post.php: get_post_types()
  • wp-includes/post.php: get_post_status_object()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::wp_rewrite_rules()
  • wp-includes/class-wp-rewrite.php: WP_Rewrite::using_index_permalinks()
  • wp-includes/rewrite.php: url_to_postid
  • Show 11 more uses Hide more uses

Used By

  • wp-includes/embed.php: wp_filter_pre_oembed_result()
  • wp-includes/class-wp-oembed-controller.php: WP_oEmbed_Controller::get_item()
  • wp-includes/post.php: is_local_attachment()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_ping()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::pingback_extensions_getPingbacks()
  • wp-includes/class-wp-xmlrpc-server.php: wp_xmlrpc_server::wp_newComment()
  • wp-includes/comment.php: pingback()
  • Show 2 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文