WP_Posts_List_Table::get_edit_link() WordPress Method

The WP_Posts_List_Table::get_edit_link() method is used to get the edit link for a given post. This is useful for displaying a link to the edit screen for a given post on the front end of a WordPress site. The get_edit_link() method takes two parameters: the post ID and the post type. The post ID is the ID of the post to get the edit link for. The post type is the post type of the post to get the edit link for.

WP_Posts_List_Table::get_edit_link( string[] $args, string $link_text, string $css_class = '' ) #

Helper to create links to edit.php with params.


Parameters

$args

(string[])(Required)Associative array of URL parameters for the link.

$link_text

(string)(Required)Link text.

$css_class

(string)(Optional) Class attribute.

Default value: ''


Top ↑

Return

(string) The formatted link string.


Top ↑

Source

File: wp-admin/includes/class-wp-posts-list-table.php

259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
protected function get_edit_link( $args, $link_text, $css_class = '' ) {
    $url = add_query_arg( $args, 'edit.php' );
 
    $class_html   = '';
    $aria_current = '';
 
    if ( ! empty( $css_class ) ) {
        $class_html = sprintf(
            ' class="%s"',
            esc_attr( $css_class )
        );
 
        if ( 'current' === $css_class ) {
            $aria_current = ' aria-current="page"';
        }
    }
 
    return sprintf(
        '<a href="%s"%s%s>%s</a>',
        esc_url( $url ),
        $class_html,
        $aria_current,
        $link_text
    );
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.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.