Title: Captions not shown in script generated html
Last modified: August 21, 2016

---

# Captions not shown in script generated html

 *  [bphil](https://wordpress.org/support/users/bphil/)
 * (@bphil)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/captions-not-shown-in-script-generated-html/)
 * I have the following problem:
 * I inserted an image into a page using the visual editor
    I gave it a caption,
   an alt-Text and I set Link to: image url Now the image is shown on the page with
   the caption and if I open it, it is shown in an overlay (I noticed that the fact
   that it opens in an overlay is somehow depended on the presence of a caption,
   I don’t know why.) Now, I create the html-code for my wordpress pages with a 
   script, and I used the following code for images I found in the source code of
   the page generated by wordpress after I did the above steps:
 * `<div style="width: 1345px" class="wp-caption alignnone"><a href="image file 
   here"><img src="image file here" alt="Alt Text" width="1335" height="979" /></
   a><p class="wp-caption-text">Caption Text</p></div>`
 * If I paste my html code into the WordPress HTML Editor and save the page, I get
   the image with the caption, but it does not open in an overlay, but when I click
   on it, the browser just loads the image file itself.
    If I then go to the wordpress
   html editor, the code above is there alright. However, if I switch to the visual
   editor and click on the edit button on the image, the caption field is empty.
 * Does anyone of you know what’s going on here? Why is the image not opened as 
   an overlay? And Why does the wordpress image editor not show the caption?
 * Any suggestions welcome!
 * WordPress 3.9.1 with Responsive Theme 1.9.6.0 and Foobox Free Version
 * EDIT: if you want to take a look at the page itself, it is this: [http://ride.i-d-e.de/issues/issue-1/nietzschesource/](http://ride.i-d-e.de/issues/issue-1/nietzschesource/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [katlove](https://wordpress.org/support/users/katlove/)
 * (@katlove)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/captions-not-shown-in-script-generated-html/#post-4965980)
 * Here’s a copy and paste from one of your working overlay photos
 *     ```
       <div class="wp-caption alignnone">
       <p>
       <a rel="lightbox[19]" href="/wp-content/uploads/issue_1/nietzschesource/pictures/picture-5.png">
       <img alt="Who is Robert Buddensieg? And where is Pforta, anyway?" src="/wp-content/uploads/issue_1/nietzschesource/pictures/picture-5.png">
       </a>
       </p>
       <p class="wp-caption-text">Who is Robert Buddensieg? And where is Pforta, anyway?</p>
       </div>
       ```
   
 * The rel=”lightbox[19]” found within the a tag creates a relationship between 
   the images in the page with the lightbox functionality. I think that’s what’s
   missing. If you want to insert images and captions via html, I would use the 
   above code snippet as a guide.
 *  Thread Starter [bphil](https://wordpress.org/support/users/bphil/)
 * (@bphil)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/captions-not-shown-in-script-generated-html/#post-4965982)
 * katlove, thanks for your reply. Stupid me, I couldn’t leave my fingers from the
   problem and tried to install another lightbox. So, just when you looked at the
   page it was not foobox running, but wp lightbox 2. WP lightbox 2 does give me
   the overlay, so it seems foobox is the culprit. But that’s not quite true, because
   something seems to be wrong with the connection to visual editor in any case.
 * Starting with the html I generated, if i go to the visual editor, as I sad, the
   caption is not shown. And if I select some option, like alignment, it is not 
   written into the html.
 * Any ideas why that is?
 * Thanks!
 *  [katlove](https://wordpress.org/support/users/katlove/)
 * (@katlove)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/captions-not-shown-in-script-generated-html/#post-4966018)
 * Hey again!
 * Oh, I wasn’t even looking at the visual editor vs. html editor issue the first
   time around…
 * Um. My guess is that in the html you still need to [use the caption shortcode](http://codex.wordpress.org/Caption_Shortcode)
   in order for the visual editor to pick up on it.
 * Do a reverse engineering trick by inserting an image, caption, alt in the visual
   editor and then viewing the html that it generates by switching to the html editor.
 * You set alignments from within the caption shortcode square brackets.

Viewing 3 replies - 1 through 3 (of 3 total)

 The topic ‘Captions not shown in script generated html’ is closed to new replies.

## Tags

 * [captions](https://wordpress.org/support/topic-tag/captions/)
 * [visual editor](https://wordpress.org/support/topic-tag/visual-editor/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [katlove](https://wordpress.org/support/users/katlove/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/captions-not-shown-in-script-generated-html/#post-4966018)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
