Site icon David Yin's Blog

Url standard of Social site link on WordPress

I put some social network button on site. The Html Validator always tell me some URL is not correct.
Ok.
I have to code it my self to replace the original code.
Original code is as shown below:

<!-- del.icio.us -->
 <a href="http://del.icio.us/post?url=<?php the_permalink() ?>&amp;title=<?php the_title ?>" title="Add to del.icio.us">Del.icio.us</a>
 <!-- /del.icio.us -->

I change it to:

<?php
$title = wp_title('',FALSE);
$tt = urlencode($title);
$tt = substr($tt,2);
?>
<!-- del.icio.us -->
<a href="http://del.icio.us/post?url=<?php the_permalink() ?>&amp;amp;title=<?php echo $tt; ?>" title="Add to del.icio.us">Del.icio.us</a>
<!-- /del.icio.us -->

Now the link is perfect, without warning from HTML Validator.
Perfect code.

Exit mobile version