I'm looking to create a WordPress secondary featured image. I started looking at a custom post type of attachment but is it possible to add a custom port type image on a regular post?

  • Possible duplicate of How can I add an image upload field directly to a custom write panel? Generally perform a search for »image upload meta box« or similar, as this has been answered numerous times. Commented Mar 6, 2018 at 20:06
  • @Nicolai DEV access to if ( ! function_exists( 'wp_handle_upload' ) ) require_once( ABSPATH . 'wp-admin/includes/file.php' ); is restricted by security
    – php_needs
    Commented Mar 6, 2018 at 20:39
  • What are you talking about, this is not even part of the answer, which is working just fine. Commented Mar 6, 2018 at 20:51

1 Answer 1


I don't want to use the many available plugins or a custom field.

Even a code only solution would use a custom field for this.

It's metadata about the post, so you use a custom field for it. That's what custom fields are.

Also, the code for your custom solution would live in a plugin, because that's where you put custom solutions.

So, as it stands, there is no answer to your question, because you placed restrictions on it that prevent any viable answer from being correct.

  • No Plugin is a requirement
    – php_needs
    Commented Mar 6, 2018 at 20:37
  • Then there is no answer. All custom code goes into plugins. That's what plugins are.
    – Otto
    Commented Mar 7, 2018 at 12:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.