the_permalink

the_permalink(int|WP_Post $post)

 

در صورتی که بخواهید به یک مطلب در وردپرس لینک دهید کافی است از تابع the_permalink استفاده کنید.

توضیحات

پارامترها

post:مقدار ورودی این پارامتر می تواند Post ID یا Post object باشد. مقدار پیشفرض آن متغیر سراسری post می‌باشد.(مقدار اختیاری، int|WP_POST)

منبع فایل:

File: wp-includes/link-template.php

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 ) );
}

یک مثال از استفاده permalink در تگ a

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>//Paste Your Code Here

این مثال یک روش رایج و پرکاربرد برای داشتن لینک به یک مطلب می باشد.

دیدگاهتان را بنویسید