Title: Help with creating meta data plugin
Last modified: August 18, 2016

---

# Help with creating meta data plugin

 *  Resolved [jakemc](https://wordpress.org/support/users/jakemc/)
 * (@jakemc)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/)
 * Hi. I’m trying to understand how functions are called from a plugin and I’m a
   bit of a newbie (sorry).
 * I’m trying to create a plugin that will allow users to associate posts from a
   particular category with a post they’re editing. I’m doing this with custom field
   by storing the id of the associated post as a meta value.
 * I have several php functions to check and list appropriate meta data all called
   by a ‘master’ function, jm_insert_fields.
 * I can’t put the other functions in the add_action because they should only be
   executed by a call from jm_insert_fields but if I while they just sit in my plugin
   file they’re not being executed at all. If I put them in edit_form_advanced.php
   directly they’re executed happily but I really want to keep my code separate.
 * How do I get these functions to execute?
 * If it helps, here’s an outline of the code in my plugin file:
 * `add_action( ‘edit_form_advanced’, ‘jm_insert_gensurgeon_fields’ );

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396807)
 * Firstly, don’t apologise for being a newbie! It’s great when new people start
   doing things for wordpress!
 * Does your function look like this?
 * `function jm_insert_gensurgeon_fields() {`
 *  function some_other_function () { ... }
 *  function another_function () { ... }
 *  function etc() { ... }
 * }
 * Because I’m not sure that will work…
 * Try defining them before you define `jm_insert...` and then call them within 
   that function, so something like this:
 * `function some_other_function () { ... }
    function another_function () { ... }
   function etc() { ... }
 * function jm_insert_gensurgeon_fields() {
    some_other_function(); another_function();
   etc(); }
 * Obviously that’s simplified, but it helps illustrate what I mean.
 *  Thread Starter [jakemc](https://wordpress.org/support/users/jakemc/)
 * (@jakemc)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396828)
 * Hi Maerk.
 * Thanks for the prompt reply and for being so encouraging. I love wordpress but
   getting into the guts of it like this is a little intimidating.
 * My functions are structured like this:
    ` function jm_get_title($postID) {...}
   function jm_has_specific_meta($postid,$meta_key) {...} function jm_list_specific_meta(
   $meta_data,$meta_key) {...}
 * function jm_insert_fields() {
    ... if($meta_data = jm_has_specific_meta($post_ID,'
   professional_speciality')) jm_list_specific_meta($meta_data,'professional_speciality');...}
 * jm_insert_fields is executed – I can see the HTML it generates – but no list 
   of meta data that should be generated by jm_list_specific_meta is visible.
 * HTH and thanks again.
 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396832)
 * Hmm… instead of
 * `function jm_has_specific_meta($postid,$meta_key) {...}`
 * try
 * `function jm_has_specific_meta() {
    global $postid, $meta_key; ... }
 * Got a feeling that won’t work either, though. It sounds like there might be a
   problem with one of your functions.
 * What does `jm_list_specific_meta()` contain?
 *  Thread Starter [jakemc](https://wordpress.org/support/users/jakemc/)
 * (@jakemc)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396835)
 * Ah! The act of sharing my problem helped me to see the solution.
 * The problem was that I didn’t have access to variables defined in the page from
   the plugin so I have to get them explicitly.
 * In particular:
    `$post_ID = $_REQUEST['post'];`
 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396836)
 * Oh, does it work now? I love it when things get solved, it’s like the sun coming
   out!
 *  Thread Starter [jakemc](https://wordpress.org/support/users/jakemc/)
 * (@jakemc)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396837)
 * Yes it does. Thanks for you help!
 * Of course, I’ve now got a trickier problem but I’ll save that for a new post…
   🙂
 *  [maerk](https://wordpress.org/support/users/maerk/)
 * (@maerk)
 * [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396838)
 * I look forward to it 😉

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Help with creating meta data plugin’ is closed to new replies.

## Tags

 * [custom](https://wordpress.org/support/topic-tag/custom/)

 * 7 replies
 * 2 participants
 * Last reply from: [maerk](https://wordpress.org/support/users/maerk/)
 * Last activity: [20 years ago](https://wordpress.org/support/topic/help-with-creating-meta-data-plugin/#post-396838)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
