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;
}

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.

  • 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? – Aeolingamenfel Nov 30 '16 at 17:20
  • What is the "general edit panel"? – Fabian Marz Nov 30 '16 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. – Aeolingamenfel Nov 30 '16 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. – Fabian Marz Dec 1 '16 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? – Aeolingamenfel Dec 1 '16 at 15:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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