Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7432599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:29:00+00:00 2026-05-29T09:29:00+00:00

In WordPress.. I’m looking for a way to add the first uploaded image in

  • 0

In WordPress.. I’m looking for a way to add the first uploaded image in a post automatically to a custom field named “Image”.

Does anyone know this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:29:01+00:00Added an answer on May 29, 2026 at 9:29 am

    I found the answer my self

    Here is the final code that adds the thumbnail url to a custom field named Image.

    function w_thumbnail_src() {
        if (has_post_thumbnail()) {
            $thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'emphasis');
            return $thumb[0]; // thumbnail url
        } else {
            return '';  // or a default thumbnail url
        }
    }
    
    
    add_action('publish_page', 'add_custom_field_automatically', 'w_thumbnail_src');
    add_action('publish_post', 'add_custom_field_automatically');
    function add_custom_field_automatically($post_id) {
    global $wpdb;
    if(!wp_is_post_revision($post_id)) {
    add_post_meta($post_id, 'Image', w_thumbnail_src(), true);
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Wordpress has a filter that automatically add paragraphs to posts. I can remove this
In Wordpress, I'm trying to add the post ID of posts I publish in
Simple Wordpress problem - get_post_meta is not retrieving custom field values. Here's the code
WordPress version : 3.1 post thumbnail field not appearing in editor section except for
WordPress spits posts in this format: <h2>Some header</h> <p>First paragraph of the post</p> <p>Second
Using wordpress, I am pulling in a custom fields from specific posts to fill
In Wordpress, the Disqus plugin allows you to choose to subscribe to a post
Wordpress is using MyISAM storage engine. MyISAM does not support transactions. How wordpress is
WordPress requires you give each blog post at least two fields: a title and
The WordPress codex has a lot of examples of how to register custom taxonomies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.