Opened 3 years ago

Last modified 21 months ago

#14760 new enhancement

wp_get_shortlink not working on pages

Reported by: mattsay Owned by:
Priority: normal Milestone: Future Release
Component: General Version: 3.0
Severity: normal Keywords: has-patch needs-testing
Cc: steph@…, lew@…, navjotjsingh@…

Description

wp_get_shortlink doesn't return anything on pages.

reason:

2196   if ( isset($post->post_type) && 'post' == $post->post_type )
2197         $shortlink = home_url('?p=' . $post->ID);

Attachments (3)

wp_get_shortlink.diff (1.3 KB) - added by sillybean 2 years ago.
Generates p= shortlinks for all content types, not just posts.
wp_get_shortlink-2.diff (1.1 KB) - added by sillybean 2 years ago.
wp_get_shortlink-3.diff (1.1 KB) - added by layotte 2 years ago.

Download all attachments as: .zip

Change History (11)

Doesn't work on custom post types either.

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release
  • Type changed from feature request to enhancement

Generates p= shortlinks for all content types, not just posts.

  • Cc steph@… added
  • Keywords has-patch needs-testing added; needs-patch removed
  • Version set to 3.0

Updated patch removes some cruft and makes sure shortlinks are generated only for public post types.

layotte2 years ago

  • Cc lew@… added

Updated patch to remove the permalink_structure check. If the user does not have permalinks turned on, this function returns a blank string as the shortlink. It should be permalink agnostic... so plugins/themes can use it without worrying about permalink checks.

Thoughts?

  • Cc navjotjsingh@… added

The latest patch is great.

+1 to latest patch.

Note: See TracTickets for help on using tickets.