^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_sample_permalink()用法示例

get_sample_permalink( int $id,  string $title = null,  string $name = null )

Get a sample permalink based off of the post name.


描述


参数

$id

(int)
(Required)
Post ID or post object.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

$title

(string)
(Optional)
Title to override the post's current title when generating the post name.

Default value: null

$name

(string)
(Optional)
Name to override the post name.

Default value: null


返回值

(array) Array containing the sample permalink with placeholder for the post name, and the post name.


源代码

File: wp-admin/includes/post.php

function get_sample_permalink($id, $title = null, $name = null) {
	$post = get_post( $id );
	if ( ! $post )
		return array( '', '' );

	$ptype = get_post_type_object($post->post_type);

	$original_status = $post->post_status;
	$original_date = $post->post_date;
	$original_name = $post->post_name;

	// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
	if ( in_array( $post->post_status, array( 'draft', 'pending', 'future' ) ) ) {
		$post->post_status = 'publish';
		$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
	}

	// If the user wants to set a new name -- override the current one
	// Note: if empty name is supplied -- use the title instead, see

更新日志

Version 描述
2.5.0 Introduced.

相关函数

Uses

  • wp-admin/includes/post.php:
    get_sample_permalink
  • wp-admin/edit-tag-form.php:
    editable_slug
  • wp-includes/formatting.php:
    untrailingslashit()
  • wp-includes/formatting.php:
    sanitize_title()
  • wp-includes/link-template.php:
    get_permalink()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/post.php:
    get_page_uri()
  • wp-includes/post.php:
    wp_unique_post_slug()
  • wp-includes/post.php:
    get_post()
  • wp-includes/post.php:
    get_post_type_object()
  • Show 5 more uses


Used By

  • wp-admin/includes/post.php:
    get_sample_permalink_html()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈