[wp-trac] [WordPress Trac] #52324: Sample permalinks unavailable for attachment pages.

WordPress Trac noreply at wordpress.org
Mon Jan 25 23:54:14 UTC 2021


#52324: Sample permalinks unavailable for attachment pages.
---------------------------+------------------------------
 Reporter:  peterwilsoncc  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Media          |     Version:
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+------------------------------

Comment (by Mista-Flo):

 Hey,

 I can reproduce the issue.

 I tried some stuff, and the issue does not seem to come from
 `get_attachment_link` function. After some debugging, I realised it's
 because the parent link (post link) is not a pretty permalink yet, so it
 will be `http://localhost:8889/?post_type=post&p=393` for example.

 Then in `get_attachment_link`, it does not accept a parent link like this,
 so it will fallback and return something like: `w.org/?attachment_id=4`.

 So the issue is rather on:
 {{{#!php
 <?php
         if ( $wp_rewrite->using_permalinks() && $parent ) {
                 if ( 'page' === $parent->post_type ) {
                         $parentlink = _get_page_link( $post->post_parent
 ); // Ignores page_on_front.
                 } else {
                         $parentlink = get_permalink( $post->post_parent );
                 }

 }}}


 `get_permalink` call does not return a pretty URL for a draft post parent.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52324#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list