Insert variable into URL
-
Hey I’m trying to concatenate two variables and use them to within a URL. However, it hasn’t been working and I’ve tried several different methods.
Here is my current code that I am trying to use, but it’s not working.<?php $proj_tit = get_post_meta($post->ID, 'wpcf-project-title', true) ?> <?php $proj_title = str_replace(" ", "-", $proj_tit) ?> <?php $custurl = "https://www.webdev.blabla.org/projects/" ?> <?php echo ('<a href="$custurl . $proj_title">$proj_tit</a>') ?>
$proj_tit is getting the value “Malware Evolution”
$proj_title is getting the value “malware-evolution”
$custurl is getting the value “https://www.webdev.blabla.org/projects/”I want to concatenate the two variables within the tags but it is not working.
With this code, my URL is this:
https://webdev.blabla.org/projects/$custurl.$proj_titleI want it to look like this:
https://webdev.blabla.org/projects/malware-evolutionI’m not sure why but the link is autmatically getting the “https://webdev.blabla.org/projects” part of the URL from somwhere. It’s not getting this from my $custurl variable.
Can anybody please help me? I’m lost as to what I should do.
- The topic ‘Insert variable into URL’ is closed to new replies.