• Resolved cconstantine

    (@cconstantine)


    I’m wondering if there’s a hook I can use with add_action() to add FIGURE and FIGCAPTION markup?

    • This topic was modified 11 months, 3 weeks ago by cconstantine.

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

Viewing 1 replies (of 1 total)
  • Plugin Author Rob @ 5 Star Plugins

    (@5starplugins)

    Hi @cconstantine you can use the same RSS hooks we use, is_feed(), has_post_thumbnail(), get_the_post_thumbnail(), etc.

    For example:

    function add_figure_to_rss_content($content) {
    if (is_feed()) {
    global $post;

    // Check for a featured image
    if (has_post_thumbnail($post->ID)) {
    // Get the featured image HTML
    $thumbnail_html = get_the_post_thumbnail($post->ID, 'large');

    // Optionally add caption or figcaption if you like:
    $caption = get_post(get_post_thumbnail_id())->post_excerpt;
    $figcaption_html = $caption ? "<figcaption>" . esc_html($caption) . "</figcaption>" : "";

    // Wrap in <figure>
    $figure_html = "<figure>{$thumbnail_html}{$figcaption_html}</figure>";

    // Prepend or append to the content
    $content = $figure_html . $content;
    }
    }
    return $content;
    }
    add_filter('the_content_feed', 'add_figure_to_rss_content');

    We may be able to add this option to our plugin, so it’s a simple checkbox. We’ll evaluate this and see if it’s something we’d want to add in a future update.

Viewing 1 replies (of 1 total)

The topic ‘Adding “figure” and “figcaption” markup?’ is closed to new replies.