0

I am running the qtranslate plugin on my application and I am using get_site_url() for it's various functionalities. below I have two blocks of code. The first one I use get_site_url to view a file that was saved in "/wp-content/themes/seowp/essay_upload/" and it doesn't redirect to http://example.com/es/ however in the second one it does, thus returning a 404 error. These two blocks of code are on the same file.

     <?php $file_read = get_site_url()."/wp-content/themes/seowp/essay_upload/".$student_row->attach_essay; ?>
      <a href="<?php echo get_site_url();?>/essay-edit/?regNoIndivid=<?php echo $student_row->id;?>&type=artist">Bearbeiten</a> &nbsp;|&nbsp; 
      <a href="<?php echo $file_read;?>">Text to download essay in another language</a> 

**This second block of code is used to create a certificate on the fly when clicked using certificat_pdf.php. It is not working correctly like the code above. It even shows the correct URL when I mouseover the link but when I click on it, it redirects to http://example.com/es/certificat_pdf.php?regNoCerts=A00094094 (/es/) being the language specific page and naturally I get a 404 error.Everything works perfectly in english. The only issue is when I view it in a different language. **

        <a href="<?php echo get_site_url()."/";?>certificat_pdf.php?
    regNoCerts=<?php echo $_REQUEST['regNumber'];?>">Foreign language text</a>

1 Answers1

0

qTranslate is doing what it's supposed to do and is changing the URL of what it sees as a normal page so that the translated version is shown. The first example is not translated as it's not a page on your site.

I'd suggest making a page on your site and changing the certificat_pdf.php file to be a page template within your theme. That way, it doesn't matter that the page URL is translated as the page will still be found.

Peter HvD
  • 1,623
  • 1
  • 7
  • 14
  • certificat_pdf.php is a script that creates a PDF file. How would that work out as a page template? – Alfredo Juliano Prince Feb 22 '18 at 15:30
  • Exactly as it does now. The template tells WP to load that file for that page, but it doesn't have to use the normal theme page.php template and you don't have to have any of the normal template functions on it at all. Give it a go - just move the file into your theme folder and add `/* Template Name: Certificat PDF */` after the opening ` – Peter HvD Feb 22 '18 at 16:29
  • Thank you, I tried that and it still give sme a 404 error :( any other ideas? – Alfredo Juliano Prince Feb 24 '18 at 04:58
  • I doubt if the 404 is being caused by using a page template. Have you checked that there's no duplication of page slug with a post or category slug? How about your php - have you checked to make sure it's not hard-coding a url of the old location? Finally, have you tried resetting your permalinks? – Peter HvD Feb 26 '18 at 11:11