Search code examples
phphtmlvariablesdownloadhref

PHP variables within href tags


I have many products under many categories which contain different data sheets. When a user is on the single product page I need to output the correct download link (data sheet) for that product.

 <?php
 $path = 'http://www.ctagroup.com.au/wp-content/uploads/2016/02/';
 $filename = get_post_meta( get_the_ID(), 'File Name', true );

 echo "<a href='" $path . " " . $filename "' download>Link</a>";?>

I cannot seem to figure it out, please help!


Solution

  • Quite a few mistakes. Please try this.

    <?php
    $path = 'http://www.ctagroup.com.au/wp-content/uploads/2016/02/';
    $filename = get_post_meta( get_the_ID(), 'File Name', true );
    echo "<a href='".$path.$filename."'/download>Link</a>";
    ?>