get_sample_permalink() - WordPress 函数参考中文文档

返回介绍

get_sample_permalink()

发布于 2017-09-11 字数2755 浏览 809 评论 0

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.

$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
    Hide more uses


Used By

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

User Contributed Notes

上一篇:get_rss()

下一篇:get_sample_permalink_html()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!