phpwordpressqtranslate-x

How can I keep get_site_url() from redirecting to the language specific page?


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>

Solution

  • 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.