Longtime reader of stackoverflow but first question.
I’m working with WordPress (specifically thesis theme) in the custom_functions.php file and am finding for some reason is automatically adding the current page url. For example this code is to query the database and then loop through outputting each product in it’s own div:
$result = db_connection($query);
while ($row = mysql_fetch_array($result)) { ?>
<div class="box"><a href="">
<img src="http://www.electricbikehub.co.nz<?php echo $row['product_root_directory'] . $row['mid_size_image'] ?>">
<h2><?php echo $row['name']?></h2>
<p><?php echo $row['description_brief'];?></p>
<p><span class="multiple_product_red"><span class="multiple_product_linethrough">RRP: <?php echo $row['list_price']; ?>.</span> Our discounted price: <?php echo $row['our_price']; ?>. Includes delivery and GST.</span></p>
</a>
</div>
<?php } ?>
As you can see 3rd line says href=”” but the actual link being generated is the current page (in this case ‘http://www.electricbikehub.co.nz/?page_id=1192‘). If I add anything in the href, such as href=”something” it will just add it to the end, ie http://www.electricbikehub.co.nz/?page_id=1192something.
Any help would be greatly appreciated!
This is how a browser interprets and empty href. It assumes you want to link back to the page that you are on. This is the same as if you dont assign an action to a
<form>element.If you add any word in the href it will append it to the current page unless you:
/to the front of it telling it to append it to your base url e.g.http://www.whatever.com/something#sign in which case it is an in-page anchorEDIT: It was suggested that I add a link to help clarify the situation. I found the following site that I think does a really good job explaining the
hrefattribute of anchor tags and how it interprets URL paths. It is not incredibly technical and very human-readable. It uses lots of examples to illustrate the differences between the path types: http://www.mediacollege.com/internet/html/hyperlinks.html