Create Topic

WP Tavern Forums Create Topic

Create New Topic

Jeremy Clarke

@Bill Erickson

The reason the caption doesn’t display links is because it is using the excerpt, which doesn’t store links.

Hey Bill, FWIW I think you may be misidentifying the cause of the filtering. the_excerpt filter isn’t involved in the caption text in any way, instead it’s code in the filtering function that processes the caption text before sending the shortcode to the editor ( image_add_caption() ). It strips out , ‘ and “, then runs addslashes() on whatever is left. This code is important because as things stand if those characters are present in the shortcode attribute then the shortcode display functions will choke on them when you load the actual post.

The strange part is that the media uploader box saves whatever text you give it without filtering, so that even though when you insert the caption the HTML is stripped out, it’s still there in the database, which allows your example code to work by accessing the caption property directly rather than depending on the inserted shortcode. IMHO that should probably be changed, so that the uploader settings match the actual output you get when you insert the shortcode into a post.

That said, maybe your method is on to something. If the shortcode used the database rather than it’s own attributes to fetch the caption text then the text wouldn’t have to work as an attribute, and would be much more powerful. The problem is all existing caption shortcodes would have vestigial text that is unused, and it would become impossible to edit the caption text from inside the HTML editor.

Oh bother.






Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.