• Resolved arthurarthur

    (@arthurarthur)


    First of all, thank you Anders for this incredible theme. I love it!

    On my homepage, some posts have a featured image and some don’t. From looking at andersnoren.se, it seems possible to set a default featured image that only appears when listing posts, but not when viewing individual posts. Is this some option somewhere in the theme or do I need custom code for this?

    • This topic was modified 10 months, 1 week ago by arthurarthur.
Viewing 1 replies (of 1 total)
  • Thread Starter arthurarthur

    (@arthurarthur)

    add_filter('post_thumbnail_html', function($html, $post_id, $post_thumbnail_id, $size, $attr) {

    if (!empty($html)) {
    return $html;
    }

    if (wp_is_mobile()) {
    return ''; // Don't display anything on mobile
    }

    $default_image_url = 'ADD LINK HERE';

    $alt = esc_attr(get_the_title($post_id));
    return '<img src="' . esc_url($default_image_url) . '" alt="' . $alt . '" class="wp-post-image" />';
    }, 10, 5);
    • This reply was modified 10 months, 1 week ago by arthurarthur.
Viewing 1 replies (of 1 total)

The topic ‘Default featured image for posts’ is closed to new replies.