• Hello, there. I’m a fellow WP dev.
    I was trying to use the `get_video_thumbnail()’ function in multiple post pages, such as home and archive pages, to be able to use those thumbnails for a video slider. However, I kept getting Apache crashes on local install and 500 Errors on live install, so I figured the problem was coming from the fact that the function had been coded for single post use only, and I decided to take a look inside the function’s code.
    It seems the problem in multiple post pages is generated by the chunk of the code that fetches the thumbnail if none exists (lines 256 to 306), so if you wrap that whole chunk inside an if statement to check if single posts are being showed, it works just fine on all pages, ie, retrieves the thumb if is set for all WP pages and fetches a thumbnail only in single post pages:

    // If the thumbnail isn't stored in custom meta, fetch a thumbnail
    else {
        if( is_single() ) {
            // lines 259 to 304
        }
    }

    I hope that helps!

    https://wordpress.org/plugins/video-thumbnails/

Viewing 1 replies (of 1 total)
  • Thread Starter Marventus

    (@marventus)

    Actually, if you do if( is_single() ) it will break the thumbnail generation process in admin pages, so it should be:

    if( is_single() || is_admin() ) {

Viewing 1 replies (of 1 total)

The topic ‘get_video_thumbnail() function in multiple post pages’ is closed to new replies.