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

  • Home
  • SEARCH
  • 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 8366965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:02:46+00:00 2026-06-09T13:02:46+00:00

I wanted to create a plugin to batch manage posts’ custom field data. I

  • 0

I wanted to create a plugin to batch manage posts’ custom field data. I know I can add post meta by adding a meta box in the post edit screen and using add_action('save_post', 'function_to_update_meta') to trigger add meta functions.

But I don’t know how to trigger the add_post_meta function in an admin menu page (such as a custom admin menu). How to do that?

Thank you in advance!

  • 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-06-09T13:02:47+00:00Added an answer on June 9, 2026 at 1:02 pm

    The answer was from the same question I asked somewhere else

    And I created my version of example

    I added some console.log function for testing, but this is basically doning the same thing as @Chris_() answer:

    Menu callback function to generate menu content (PHP):

    function ajax_menu_callback() {
    ?>
    <div class="wrap">
        <div id="icon-themes" class="icon32"></div>
        <h2>Test</h2>
        <br />
        <form>
            <input id="meta" type ="text" name="1" value="<?php echo esc_html( get_post_meta( 1, 'your_key', true) ); ?>" />
            <?php submit_button(); ?>
        </form>
    </div>
    <?php
    }
    

    Then the javascript to print on the admin side (javascript, don’t forget to include a jquery library):

    jQuery(document).ready(function() {
        $("form").submit(function() {
            console.log('Submit Function');
            var postMeta = $('input[name="1"]').val();
            console.log(postMeta);
            var postID = 1;
            var button = $('input[type="submit"]');
            button.val('saving......');
            $.ajax({
                data: {action: "update_meta", post_id: postID, post_meta: postMeta, },
                type: 'POST',
                url: ajaxurl,
                success: function( response ) { console.log('Well Done and got this from sever: ' + response); }
            }); // end of ajax()
            return false;
        }); // end of document.ready
    }); // end of form.submit
    

    Then the PHP function handle update_post_meta (PHP):

    add_action( 'wp_ajax_update_meta', 'my_ajax_callback' );
    function my_ajax_callback() {
        $post_id = $_POST['post_id'];
        $post_meta = $_POST['post_meta'];
        update_post_meta( $post_id, 'your_key', $post_meta );
        echo 'Meta Updated';
        die();
    } // end of my_ajax_callback()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just wanted to know can we create web service with Axis2 without using eclipse
I wanted to create jquery plugin & started off creating a sample jquery plugin...But
I wanted to create an new gesture keyboard which can be used by all
I would like to create a migration to add test data to other developer's
I'm using JavaCC to create a language plugin for Eclipse and I wanted to
For example I wanted to create a simple plugin that supports multi-rename. I was
I have a plugin project, i wanted to create & save a file in
I wanted to create simple plugin using jquery. Also suggest me standard practice while
I'm following the tutorial here: http://docs.jquery.com/Plugins/Authoring I just wanted to create a simple plugin
I wanted to create smth similar to this one Kansas county map where user

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.