A shorter way to set up links in Wordpress posts?
It bugs me that every time I add a link in the content area of a Wordpress page or post, I have to type the entire
<a href="http://mywebsite.com/images/myimage.jpg">
text as opposed to quick formats available in php or the css file, such as
<a href="url(images/myimage.jpg)">
.
Is writing out the entire domain every time the only way to set the link up, or am I missing out on a shortcut?
Solutions
Besides using the "Add Media" button above the text entry, there is no default way to enter that little info. You can register some short code so you could write it like
[img src="myimage.jpg"]
in your
text editor
.
functions.php
function img_func( $atts ) {
extract( shortcode_atts( array(
'src' => 'something'
), $atts ) );
$route = 'http://mywebsite.com/images/'.$src;
return $route;
}
add_shortcode( 'img', 'img_func' );