Call to undefined function wp_generate_attachment_metadata()

Question

In content-attachment.php I have:

            /* preview for PDFs*/
            if('' === $ai) {
                wp_generate_attachment_metadata( $the_ID, wp_upload_dir() );
            }

And it throws this error:

 Fatal error: Call to undefined function wp_generate_attachment_metadata() in /home/content/xx/html/example/wp-content/themes/twentyseventeen-child/template-parts/post/content-attachment.php on line 110

Per another question here, I tried adding the following to the top of this file:

 require_once( ABSPATH . 'wp-admin/includes/image.php' );

And that generates a slew of errors like this:

  Warning: preg_match() expects parameter 2 to be string, array given in /home/content/55/8933555/html/seatacnoise/wp-includes/functions.php on line 2797

Now what?

0
jchwebdev 4 months 0 Answers 23 views 0

Leave an answer