the_permalink

函数
the_permalink ( $post = 0 )
参数
  • (int|WP_Post) $post Optional. Post ID or post object. Default is the global `$post`.
    Required:
定义位置
相关方法
get_the_permalinkthe_permalink_rssget_permalinkpost_permalinkget_sample_permalink
引入
1.2.0
弃用
-

permink是一个WordPress函数,它显示当前文章或指定文章的固定链接: 该函数检索循环中文章的固定链接,并输出封装在锚标记中的URL。

显示当前文章的固定链接。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function the_permalink( $post = 0 ) {
/**
* Filters the display of the permalink for the current post.
*
* @since 1.5.0
* @since 4.4.0 Added the `$post` parameter.
*
* @param string $permalink The permalink for the current post.
* @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0.
*/
echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );
}
function the_permalink( $post = 0 ) { /** * Filters the display of the permalink for the current post. * * @since 1.5.0 * @since 4.4.0 Added the `$post` parameter. * * @param string $permalink The permalink for the current post. * @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0. */ echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) ); }
function the_permalink( $post = 0 ) {
	/**
	 * Filters the display of the permalink for the current post.
	 *
	 * @since 1.5.0
	 * @since 4.4.0 Added the `$post` parameter.
	 *
	 * @param string      $permalink The permalink for the current post.
	 * @param int|WP_Post $post      Post ID, WP_Post object, or 0. Default 0.
	 */
	echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );
}

常见问题

FAQs
查看更多 >