wp_ajax_sample_permalink() WordPress Function

The wp_ajax_sample_permalink() function is used to create a sample permalink for a post. This is typically used when the user is creating a new post, and the permalink field is empty. This function will take the post title and generate a permalink based on it. This is just a sample permalink, and the user can still change it if they want.

wp_ajax_sample_permalink() #

Ajax handler to retrieve a sample permalink.


Source

File: wp-admin/includes/ajax-actions.php

function wp_ajax_sample_permalink() {
	check_ajax_referer( 'samplepermalink', 'samplepermalinknonce' );
	$post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0;
	$title   = isset( $_POST['new_title'] ) ? $_POST['new_title'] : '';
	$slug    = isset( $_POST['new_slug'] ) ? $_POST['new_slug'] : null;
	wp_die( get_sample_permalink_html( $post_id, $title, $slug ) );
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More