Variable problem

Hi guys, I have a very basic problem. I am trying to link data to another field from a working one but the variable is not being added. The one in bolded black is the original, and the one in red doesn’t work. I needed to take away the $link_text since the text linked will be .$val. (price) In essence, I want to link [price] ith the [main link] so when users click on [price] they are taken to that site’s link.

Can someone please tell me what I’m missing?

echo "Rating More Info"; echo "";
		$i = 1;		
		$class = 'alternate';
		foreach ($posts as $post) {
			$class = ($class == 'alternate') ? '' : 'alternate';
			echo "<tr class='$class'>";
			$img = WP_PLUGIN_URL . "/review-site/images/" . $i . ".png";
			echo "<td class='comparison_rank'><img src='$img' alt='$i' /></td>";
			echo "<td class='comparison_title'>" . $post->post_title . "</td>";
			foreach ($fields as $field) {
				if (!empty($field)) {
					$val = get_post_meta($post->ID, $field, true);
					echo "<td class='comparison_field'>[b]<a href='" . visit_site_link($post->ID) . "'>"[/b] . $val . "</td>";
			$rating = get_average_rating($post->ID);

			echo "<td class='comparison_average'>" . num_to_stars($rating) . "</td>";
			echo "<td class='comparison_links'>";
			[b]echo visit_site_link($link_text, $post->ID);[/b]
			echo "<br /><a href='" . get_permalink($post->ID) . "'>reviews</a>";
			echo "</td>";
			echo "</tr>";
		echo "</table>";</blockquote>

I doubt you can just exclude the $link_text from the function. Without seeing that function I can only guess…

What if you used an empty string in place of $link_text?

[php]echo “

<a href=’” . visit_site_link(’’, $post->ID) . “’>” . $val . “”;[/php]

Thanks for the answer, unfortunately it didn’t work. Everything I try, end up with linking to the index page. This is the visit_site_link function …I tried $url didn’t work.

/* * Displays a link to the URL saved with the post for a "Visit Site" type affiliate link */ function visit_site_link($text = 'Visit This Site', $custom_id = null) { global $id, $wpdb; $pid = $id; if (is_numeric($custom_id)) $pid = $custom_id;
	$url = get_post_meta($pid, '_rs_link', true);
	if (!empty($url) && $url != 'http://')
		echo '<a href="' . $url . '" target="_blank" rel="nofollow">' . $text . '</a>';		

Well, you could modify the visit_site_link function to override the url. For example

function visit_site_link($text = ‘Visit This Site’, $custom_id = null, $custom_url = null) {
global $id, $wpdb;
$pid = $id;
if (is_numeric($custom_id))
$pid = $custom_id;

$url = ($custom_url ? $custom_url : get_post_meta($pid, '_rs_link', true));
if (!empty($url) && $url != 'http://')
	echo '<a href="' . $url . '" target="_blank" rel="nofollow">' . $text . '</a>';


Then you could specify any URL

visit_site_link(’’, $post->ID, ‘’)

Also after seeing the function, I think you would want to do this

echo “

” . visit_site_link($val, $post->ID, ‘’) . “”;[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service