I have created a simple shortcode from looking at tutorials:
<?php
/*
Plugin Name: GT NoTranslate Shortcode
Description: Shortcode to wrap a span with the "notranslate" span around text.
Version: 0.1 BETA
Author: Andrew Truckle
Author URI: http://www.trucklesoft.co.uk
*/
function trucklesoft_gtspan_shortcode()
{
return '<span class="notranslate">' . $content . '</span>';
}
add_shortcode( 'ts', 'trucklesoft_gtspan_shortcode' );
?>
I have placed the code in trucklesoft.php
and put it in a folder called trucklesoft
in the plugins
folder.
I activated the plugin. Yet, when I edit my page and I change the title to:
[ts]This is the heading[/ts]
And preview it it shows as:
[ts]This is the heading[/ts]
Instead of <span class="notranslate">This is the heading</span>
.
What am I doing wrong?
I had to make changes to the code in the first instance anyway for it to work in the content of the page:
<?php
/*
Plugin Name: GT NoTranslate Shortcode
Description: Shortcode to wrap a span with the "notranslate" span around text.
Version: 0.1 BETA
Author: Andrew Truckle
Author URI: http://www.trucklesoft.co.uk
*/
function trucklesoft_gtspan_shortcode($atts, $content = null)
{
return '<span class="notranslate">' . $content . '</span>';
}
add_shortcode( 'ts', 'trucklesoft_gtspan_shortcode' );
?>
The location where I was initially trying to use this plugin was the title. When I view the source it shows it in this location:
<header class="entry-header">
<h1 class="entry-title">Test</h1>
</header><!-- .entry-header -->