WordPress.org

Ready to get started?Download WordPress

Forums

Mass insert thumbnail to posts via MySQL (3 posts)

  1. Nile Flores
    Member
    Posted 1 year ago #

    I have a site that has 300 posts that do not have an assigned thumbnail to them. I do not want to put a PHP statement for featured thumbnail on the front end, but be able to use 1 thumbnail image (like default-featured-thumbnail.jpg )

    Now, I know if I load it to the media library, WordPress will attach a number to it (meta_id)... so I also know that number will be the one I want to mass insert into posts that do not have an assigned thumbnail (meta key is _thumbnail_id in the wp_postmeta). However, I also see that I need to have post_id

    I am trying to wrap my head around a code to do this and thought I would pick anyone's brain to be able to come up with a code that runs the query that will do this.

  2. Jonathan Dingman
    Member
    Posted 1 year ago #

    Why do you not want to put a PHP statement as a default? Long term, that's going to be a much better route and easier to manage.

    Think about if you ever want to change that default thumbnail...you'd have to delete it, reupload it, and reset every post again.

    Using a if ( !thumbnail ) { use this } is a LOT easier. It's really not much of a toll on your server either, if you're concerned about server resources. PHP is very fast when it comes to this.

  3. Nile Flores
    Member
    Posted 1 year ago #

    This is not for my site and the person it is for is a friend that will not be changing her thumbnails. I have already discussed this with her and that is what she asked about.

    I told her the same thing you did.

Topic Closed

This topic has been closed to new replies.

About this Topic