Update: If you don’t mind ugly permalinks on your wp-document-revision urls, then this crude fix will work. In my case, if you set the permalinks settings to “Plain”, then the .pdf will open correctly without a 404 error. This makes the permalinks ugly for the rest of the website. My solution was to modify the file at “/wp-content/plugins/wp-document-revisions/includes/class-wp-document-revisions.php”.
Starts at Line 596. This is my exact code. I commented out the original code.
______________________________________________________________________________
// if no permastruct
if ( ” === $wp_rewrite->permalink_structure || in_array( $document->post_status, array( ‘pending’, ‘draft’ ), true ) ) {
$link = site_url( ‘?post_type=document&p=’ . $document->ID );
if ( $revision_num ) {
$link = add_query_arg( ‘revision’, $revision_num, $link );
}
return apply_filters( ‘document_permalink’, $link, $document );
}
$link = site_url( ‘?post_type=document&p=’ . $document->ID );
if ( $revision_num ) {
$link = add_query_arg( ‘revision’, $revision_num, $link );
}
return apply_filters( ‘document_permalink’, $link, $document );
// build documents/yyyy/mm/slug
//$extension = $this->get_file_type( $document );
//$timestamp = strtotime( $document->post_date );
//$link = home_url() . ‘/’ . $this->document_slug() . ‘/’ . date( ‘Y’, $timestamp ) . ‘/’ . date( ‘m’, $timestamp ) . ‘/’;
//$link .= ( $leavename ) ? ‘%document%’ : $document->post_name;
//$link .= $extension;
//$link = apply_filters( ‘document_permalink’, $link, $document );
//return $link;
}
__________________________________________________________________________________
Doing this forced the ugly permalink only on my documents that I posted, which allowed me to keep my WordPress permalink settings on “Post name”. It’s ugly, but it works.