0

I have a custom post, and a custom column on that post, but there is no way to actually edit the data in that column for any particular post. I tried a few things, including hooking to the {name}_edit_form action, but couldn't get anything to work. Any idea what I'm doing wrong?

Custom Column Code

Below is the code that is called on the manage_[custom post-type name]_product_columns filter. This works correctly and creates the column, but there's no UI to edit it when I try to edit a custom post of that type.

public static function setCustomProductColumns($columns){
    $columns = [
        'cb' => '<input type="checkbox" />',
        'title' => __('Name'),
        'pack' => __("Pack")
    ];

    return $columns;
}
1

1 Answer 1

1

To edit custom data via the quick edit form you have to add a meta box via the quick_edit_custom_box action hook. Good examples are provided in the documentation. To edit existing values you need to add some Javascript, which is also available in the provided link.

12
  • This is specifically for quick edit only. I'm talking about the general edit panel, unless the quick edit hook also applies to the normal edit page? Nov 30, 2016 at 17:20
  • What is the "general edit panel"? Nov 30, 2016 at 19:29
  • When the user clicks on the edit button for a post (not quick edit), they're brought to a new page. I wasn't clear on that, sorry. That's the page I'm talking about. Nov 30, 2016 at 21:59
  • Ah! So it's the regular post page. Where does the data from the column come from? Regularly you either save custom post data as post_meta via the save_post hook or by adding a term/taxonomy and assign it to them. Dec 1, 2016 at 9:27
  • I'm using a custom metadata column. I'm not talking about just the save_post hook though; I need to also (I assume) give WordPress some HTML for the input for that data too...which I'm also wondering how to do? Dec 1, 2016 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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