Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › the wrong URL for the direct download of the PDF › Reply To: the wrong URL for the direct download of the PDF
Okay!
So on the first screenshot you have the “dedo_download” post type selected. That is probably causing the issue. If the files are already in the media library, then you can deselect that option. It’s probably only a post type for storing the download metadata and it’s non-displayable.
If it’s needed, then I guess the only way to fix that is via a custom code, as it seems like the incorrect url is returned by wordpress.
Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.
add_filter(
'asp_results',
function ( $results ) {
foreach ( $results as &$r ) {
if ( isset($r->post_type) && $r->post_type === 'dedo_download' ) {
$r->link = get_site_url() . '/' . "?ddownload=$r->id";
}
}
return $results;
},
10,
1
);
To restrict the results to specific categories please check this documentation.