Support » Fixing WordPress » Caption text not showing

  • Hello.

    I’m struggling to add css to the caption text. It simples doesn’t recognize it. It appears as follows: https://i.stack.imgur.com/lBU2P.png

    I used the follows code in the CSS:

    .wp-caption-text {background: url(images/h6.png) no-repeat; font-size: 12px !important; text-align: left; font-weight: normal; line-height: 21px; color: #a1a1a1; min-height: 20px; font-family: Open Sans; font-style: normal; letter-spacing: -1px; text-align: left !important; padding-left: 30px !important; margin-top:0px;}

    Thanks in advance.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Joy

    (@joyously)

    Your captioned images are not being output correctly. The caption shortcode is not being run. This is a WordPress shortcode, so it should work, but do you have a plugin that would disable it or change how it works? Was this content entered using the classic editor or the new block editor? Does it look correct in the editor or in the Preview from the editor?

    Hello, @joyously.

    I’m using the classic editor and yes, it looks correct in the editor, but it doesn’t in the preview.

    Joy

    (@joyously)

    It could be your theme has a filter on the caption that is messing it up. The syntax of the output is a little strange, as if it was only half evaluated by the shortcode handler. Normal caption shortcodes would have the caption text as part of the shortcode like caption="Howie B e The Edge", but your page shows that after the image and still inside the [] for the caption shortcode.
    Maybe you should look in the HTML of your page and see if the caption shortcode is malformed, and the shortcode handler can’t interpret it correctly.

    Here’s the function that should output it, by the way:
    https://developer.wordpress.org/reference/functions/img_caption_shortcode/

    Do I need to copy the entire source of this function in the function file? Or do I have to do something else?

    Thanks, @joyously.

    Joy

    (@joyously)

    No! You shouldn’t have to do anything with code.
    You are looking at your page in HTML mode to see if your caption shortcode is messed up. Or you can just delete it and re-insert the image into the page.
    It may be the HTML is wrong or you have a theme or plugin that is messing it up.

    I re-inserted the image but the result is the same. I don’t know what is wrong.

    Joy

    (@joyously)

    Can you try installing the Health Check plugin? In the Troubleshoot mode, you can disable the theme and plugins for your user only, to isolate if the problem is in an add-on or in core WordPress.

    @joyously

    I installed. The problem is the theme. I also noticed that the plugins Contact Form 7, Table Press and the WP Gallery are not displaying theirselves, it only appears their code on the page. What can I do in this situation?

    Joy

    (@joyously)

    Ask in the theme’s support forum. They must be doing something that messes up shortcodes.
    If it is a theme in the WordPress repository, please report it (go to the theme’s .org page and click the Report button) or tell me here and I will, because themes should not be doing anything with shortcodes.
    If it’s not from here, we don’t support that theme here in these forums.

    I finally found the problem! It’s the Classic Editor plugin. If I switch to the block editor the caption is displayed normally. Strange, isn’t it?

    Joy

    (@joyously)

    Yes, that’s strange because you said it was the theme.
    The editor is not involved in the page that is generated by hitting Preview or when viewing the front end, although it is involved when in the editor page in Visual mode.
    So this doesn’t make much sense. (I use the Classic Editor plugin and so do millions of other users, and my shortcodes work.)

    • This reply was modified 2 weeks, 3 days ago by Joy.
Viewing 11 replies - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.