<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Filter caption-Shortcode in WordPress</title>
	<atom:link href="http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Tue, 22 May 2012 12:01:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Stuart</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-6172</link>
		<dc:creator>Stuart</dc:creator>
		<pubDate>Sat, 25 Dec 2010 20:17:36 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-6172</guid>
		<description>I&#039;ve been trying to figure this out, too using the code on this page but it doesn&#039;t seem to work. Here is the code I&#039;m using. Am I missing something?

Thanks so much.

 

   add_filter( &#039;disable_captions&#039;, create_function(&#039;$a&#039;, &#039;return true;&#039;) );
    add_filter( &#039;img_caption_shortcode&#039;, create_function(&#039;$a, $b, $c&#039;, &#039;return $c;&#039;), 10, 3 );

    function MYNAME_img_caption_shortcode($attr, $content = null) {
     
    // Allow plugins/themes to override the default caption template.
    $output = apply_filters(&#039;img_caption_shortcode&#039;, &#039;&#039;, $attr, $content);
    if ( $output != &#039;&#039; )
    return $output;
    
    extract(shortcode_atts(array(
    &#039;id&#039; =&gt; &#039;&#039;,
    &#039;align&#039; =&gt; &#039;alignnone&#039;,
    &#039;width&#039; =&gt; &#039;&#039;,
    &#039;caption&#039; =&gt; &#039;&#039;
    ), $attr));
    
    if ( 1 &gt; (int) $width &#124;&#124; empty($caption) )
    return $content;
    
    if ( $id ) $id = &#039;id=&quot;&#039; . $id . &#039;&quot; &#039;;
     
    return &#039;&#039;
    . do_shortcode( $content ) . &#039;&#039; . $caption . &#039;&#039;;
    }
     
    add_shortcode(&#039;wp_caption&#039;, &#039;MYNAME_img_caption_shortcode&#039;);
    add_shortcode(&#039;caption&#039;, &#039;MYNAME_img_caption_shortcode&#039;);</description>
		<content:encoded><![CDATA[<p>I've been trying to figure this out, too using the code on this page but it doesn't seem to work. Here is the code I'm using. Am I missing something?</p>
<p>Thanks so much.</p>
<p>   add_filter( 'disable_captions', create_function('$a', 'return true;') );<br />
    add_filter( 'img_caption_shortcode', create_function('$a, $b, $c', 'return $c;'), 10, 3 );</p>
<p>    function MYNAME_img_caption_shortcode($attr, $content = null) {</p>
<p>    // Allow plugins/themes to override the default caption template.<br />
    $output = apply_filters('img_caption_shortcode', '', $attr, $content);<br />
    if ( $output != '' )<br />
    return $output;</p>
<p>    extract(shortcode_atts(array(<br />
    'id' =&gt; '',<br />
    'align' =&gt; 'alignnone',<br />
    'width' =&gt; '',<br />
    'caption' =&gt; ''<br />
    ), $attr));</p>
<p>    if ( 1 &gt; (int) $width || empty($caption) )<br />
    return $content;</p>
<p>    if ( $id ) $id = 'id="' . $id . '" ';</p>
<p>    return ''<br />
    . do_shortcode( $content ) . '' . $caption . '';<br />
    }</p>
<p>    add_shortcode('wp_caption', 'MYNAME_img_caption_shortcode');<br />
    add_shortcode('caption', 'MYNAME_img_caption_shortcode');</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deschamps_24</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-4047</link>
		<dc:creator>deschamps_24</dc:creator>
		<pubDate>Wed, 28 Apr 2010 13:25:19 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-4047</guid>
		<description>Hi
i am trying to find a solution to put a language filter before the caption output in the built-in wordpress gallery, as I have a multilanguage blog and would like to display different captions in each language. I haev not had any luck so far. Normally, I just insert apply_filter(&#039;the_title&#039;, $title) or &#039;the_content&#039;, etc. in plugins or functions, but in this one, I have no idea where to insert this filter, and what the first element of the filter should be. Help would be very much appreciated! THANK YOU.</description>
		<content:encoded><![CDATA[<p>Hi<br />
i am trying to find a solution to put a language filter before the caption output in the built-in wordpress gallery, as I have a multilanguage blog and would like to display different captions in each language. I haev not had any luck so far. Normally, I just insert apply_filter('the_title', $title) or 'the_content', etc. in plugins or functions, but in this one, I have no idea where to insert this filter, and what the first element of the filter should be. Help would be very much appreciated! THANK YOU.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-3655</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Sat, 06 Mar 2010 19:29:57 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-3655</guid>
		<description>I just published a gallery plugin that expands its control to include captions thanks to your post.  Very helpful!

I expanded on the shortcode concept a bit and include a new container shortcode for captions (captiongroup) that if you sandwich any captions within, they will be rendered inside a styled container.... sort of a &quot;mini gallery&quot;.  Excellent for having multiple sets of images dispersed throughout a post for discussion purposes.

You can see the plugin demonstrated  live here:
http://www.dyerware.com/main/products/gallery-and-caption/gallery-and-caption-plugin-for-wordpress.html

Again my thanks!</description>
		<content:encoded><![CDATA[<p>I just published a gallery plugin that expands its control to include captions thanks to your post.  Very helpful!</p>
<p>I expanded on the shortcode concept a bit and include a new container shortcode for captions (captiongroup) that if you sandwich any captions within, they will be rendered inside a styled container.... sort of a "mini gallery".  Excellent for having multiple sets of images dispersed throughout a post for discussion purposes.</p>
<p>You can see the plugin demonstrated  live here:<br />
<a href="http://www.dyerware.com/main/products/gallery-and-caption/gallery-and-caption-plugin-for-wordpress.html" rel="nofollow">http://www.dyerware.com/main/products/gallery-and-caption/gallery-and-caption-plugin-for-wordpress.html</a></p>
<p>Again my thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rami</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-2079</link>
		<dc:creator>rami</dc:creator>
		<pubDate>Thu, 03 Dec 2009 00:30:47 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-2079</guid>
		<description>wow, i was looking for solution to this problem. thanks!</description>
		<content:encoded><![CDATA[<p>wow, i was looking for solution to this problem. thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-2010</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Mon, 16 Nov 2009 16:21:31 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-2010</guid>
		<description>@Arpit, glad to save you some hours :)
@Laurent, just hit you ;)</description>
		<content:encoded><![CDATA[<p>@Arpit, glad to save you some hours <img src='http://wpengineer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> <br />
@Laurent, just hit you <img src='http://wpengineer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arpit Jacob</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-2004</link>
		<dc:creator>Arpit Jacob</dc:creator>
		<pubDate>Sat, 14 Nov 2009 14:48:58 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-2004</guid>
		<description>Just Perfectly what I needed, You turned up in my google search thankfully otherwise I would have spent hours trying to figure this out.</description>
		<content:encoded><![CDATA[<p>Just Perfectly what I needed, You turned up in my google search thankfully otherwise I would have spent hours trying to figure this out.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Laurent</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-1943</link>
		<dc:creator>Laurent</dc:creator>
		<pubDate>Tue, 03 Nov 2009 22:35:02 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-1943</guid>
		<description>I&#039;ll give it a try asap, it&#039;s a dumb thing, why didn&#039;t I think about that ?
(hit me :))</description>
		<content:encoded><![CDATA[<p>I'll give it a try asap, it's a dumb thing, why didn't I think about that ?<br />
(hit me <img src='http://wpengineer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-1942</link>
		<dc:creator>Alex</dc:creator>
		<pubDate>Tue, 03 Nov 2009 20:50:07 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-1942</guid>
		<description>With this function it won&#039;t change anything as you recognized, In this case we just put out everything via dl-list, which is a better semantic , If you like to change the output, your have to adjust the syntax of return.
&lt;pre lang=&quot;php&quot;&gt;return &#039;&lt;dl &#039; . $id . &#039;class=&quot;wp-caption &#039; . $align . &#039;&quot; style=&quot;width: &#039; . (10 + (int) $width) . &#039;px&quot;&gt;&lt;dt&gt;&#039;
 . do_shortcode( $content ) . &#039;&lt;/dt&gt;&lt;dd class=&quot;wp-caption-text&quot;&gt;&#039; . $caption . &#039;&lt;/dd&gt;&lt;/dl&gt;&#039;;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>With this function it won't change anything as you recognized, In this case we just put out everything via dl-list, which is a better semantic , If you like to change the output, your have to adjust the syntax of return.</p>
<pre lang="php">return &#039;&lt;dl &#039; . $id . &#039;class=&quot;wp-caption &#039; . $align . &#039;&quot; style=&quot;width: &#039; . (10 + (int) $width) . &#039;px&quot;&gt;&lt;dt&gt;&#039;
 . do_shortcode( $content ) . &#039;&lt;/dt&gt;&lt;dd class=&quot;wp-caption-text&quot;&gt;&#039; . $caption . &#039;&lt;/dd&gt;&lt;/dl&gt;&#039;;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Laurent</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-1936</link>
		<dc:creator>Laurent</dc:creator>
		<pubDate>Sat, 31 Oct 2009 22:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-1936</guid>
		<description>I can&#039;t get it, I&#039;m sorry... 
I put that code at the end of my functions.php and nothing... It just remove the old shortcodes but no replacement at all... Am I forgetting something ?

add_filter( &#039;disable_captions&#039;, create_function(&#039;$a&#039;, &#039;return true;&#039;) );
add_filter( &#039;img_caption_shortcode&#039;, create_function(&#039;$a, $b, $c&#039;, &#039;return $c;&#039;), 10, 3 );
function fb_img_caption_shortcode($attr, $content = null) {
 
	// Allow plugins/themes to override the default caption template.
	$output = apply_filters(&#039;img_caption_shortcode&#039;, &#039;&#039;, $attr, $content);
	if ( $output != &#039;&#039; )
		return $output;
 
	extract(shortcode_atts(array(
		&#039;id&#039;	=&gt; &#039;&#039;,
		&#039;align&#039;	=&gt; &#039;alignnone&#039;,
		&#039;width&#039;	=&gt; &#039;&#039;,
		&#039;caption&#039; =&gt; &#039;&#039;
	), $attr));
 
	if ( 1 &gt; (int) $width &#124;&#124; empty($caption) )
		return $content;
 
	if ( $id ) $id = &#039;id=&quot;&#039; . $id . &#039;&quot; &#039;;
 
	return &#039;&#039;
	. do_shortcode( $content ) . &#039;&#039; . $caption . &#039;&#039;;
}
 
add_shortcode(&#039;wp_caption&#039;, &#039;fb_img_caption_shortcode&#039;);
add_shortcode(&#039;caption&#039;, &#039;fb_img_caption_shortcode&#039;);</description>
		<content:encoded><![CDATA[<p>I can't get it, I'm sorry...<br />
I put that code at the end of my functions.php and nothing... It just remove the old shortcodes but no replacement at all... Am I forgetting something ?</p>
<p>add_filter( 'disable_captions', create_function('$a', 'return true;') );<br />
add_filter( 'img_caption_shortcode', create_function('$a, $b, $c', 'return $c;'), 10, 3 );<br />
function fb_img_caption_shortcode($attr, $content = null) {</p>
<p>	// Allow plugins/themes to override the default caption template.<br />
	$output = apply_filters('img_caption_shortcode', '', $attr, $content);<br />
	if ( $output != '' )<br />
		return $output;</p>
<p>	extract(shortcode_atts(array(<br />
		'id'	=&gt; '',<br />
		'align'	=&gt; 'alignnone',<br />
		'width'	=&gt; '',<br />
		'caption' =&gt; ''<br />
	), $attr));</p>
<p>	if ( 1 &gt; (int) $width || empty($caption) )<br />
		return $content;</p>
<p>	if ( $id ) $id = 'id="' . $id . '" ';</p>
<p>	return ''<br />
	. do_shortcode( $content ) . '' . $caption . '';<br />
}</p>
<p>add_shortcode('wp_caption', 'fb_img_caption_shortcode');<br />
add_shortcode('caption', 'fb_img_caption_shortcode');</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://wpengineer.com/917/filter-caption-shortcode-in-wordpress/#comment-1566</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Thu, 30 Jul 2009 12:52:23 +0000</pubDate>
		<guid isPermaLink="false">http://wpengineer.com/?p=917#comment-1566</guid>
		<description>Great Help. saved me couple of hours of digging through code</description>
		<content:encoded><![CDATA[<p>Great Help. saved me couple of hours of digging through code</p>
]]></content:encoded>
	</item>
</channel>
</rss>

