• Resolved michaelde

    (@michaelde)


    Hi

    First: amazing plugin! πŸ˜€

    Now, I have one thing that I’d like to do but have not been able to figure out how: I would like to display some alt text for the shortcode when a post is previewed on the front page of my blog. I.e. at the moment only regular content of the post is displayed in the preview/excerpt of a post and the spot for the table that is loaded by the shortcode when the post is opened is left blank. Now, in my case I have a title like “See the results:” that is followed by a table. However, in the preview/excerpt directly after “See the results:” the text of the line below starts, which looks confusing.

    Is there a way to add an alt text to the short code that would display in the preview/excerpt? I.e. “See the results: Table is loading”. And when the user opens the page, the actual table is displayed.

    Thanks in advance!

    Best regards,

    Michael

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Meitar

    (@meitar)

    Is there a way to add an alt text to the short code that would display in the preview/excerpt? I.e. β€œSee the results: Table is loading”. And when the user opens the page, the actual table is displayed.

    No. WordPress strips complex HTML from the post excerpts by default (using a filter). You can do this yourself if you want by putting whatever HTML you want in the excerpt using the the_excerpt filter, but you have to write this function yourself.

    • This reply was modified 8 years, 9 months ago by Meitar.
    Thread Starter michaelde

    (@michaelde)

    Ok, thanks for the response and the idea!

    I’m actually using a different strategy that takes advantage of WP’s behavior: I’ve added a <div> element after your shortcode with a special class that is hidden from the actual posts with CSS but because the HTML is stripped from the excerpts is displayed there πŸ™‚

    Best,

    Michael

    Plugin Author Meitar

    (@meitar)

    Okay. I suppose that works but is fragile. Reconsider using the WordPress filter hook; that’s what it’s there for.

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

The topic ‘Show alt text for shortcode in post preview’ is closed to new replies.