Tagged: 

Viewing 8 reply threads
  • Author
    Posts
    • #4919
      conkid
      Member

      Hello,

      Looking for help from the community on this one. Adam Silverstein has put out a wordpress plugin: https://wordpress.org/plugins/wp-post-meta-revisions/

      It’s called wp-post-meta-revisions and it saves post meta revisions by adding custom meta field names to a simple array. From what I can tell it is being developed to be implemented into core long-term.

      I’ve got a field in my custom post type ‘assets’ labeled ‘asset_type’. I implement the following code:
      /*Save Custom Meta for Revisions*/

      function add_meta_keys_to_revision( $keys ) {
      $keys[] = ‘asset_type’;
      return $keys;
      }
      add_filter( ‘wp_post_revision_meta_keys’, ‘add_meta_keys_to_revision’ );

      When I look in the database I can see the entries being made successfully:
      176 _wp_post_revision_meta_keys a:2:{i:0;s:10:”asset_type”;i:1;s:10:”model_type”;}

      When I use built in revision viewer I only see the title. Not sure if this is by design or not? I love piklist but without a method to save revisions I’m going to have trouble bringing into my workflow.

      FYI I’m working on an converting an intranet theme I’ve built with advanced custom fields and several other plugins to piklist.

    • #5425
      Steve
      Keymaster

      This is working in our latest beta.

      Just remember When you register your post type, you need to specify that it supports revisions. Use the “supports” parameter.

    • #5427
      conkid
      Member

      Steve – I can confirm revisions are now working properly.

      A couple of things to comment…

      When the revisions are stored the values returned from the viewer show the ID of custom taxonomy rather than the string. You can see in my screenshot how it isn’t really easy to decipher the meaning from the ID. Wondering if this is by design?

      Secondly, having issues with the admin columns displaying properly with — ‘show_admin_column’ => true — the columns show but the data does not display.

      Attachments:
      You must be logged in to view attached files.
    • #5430
      Steve
      Keymaster

      @conkid– Term ID’s are how WordPress saves it’s data. Everything in WordPress is saved with ID’s.

      Term data is showing up for me in the demos, which is set to show_admin_column to true. Feel free to email your code to [email protected] and we’ll take a look.

    • #5431
      conkid
      Member

      Is there a way to convert the term id to the term so the data is readable?

    • #5432
      Steve
      Keymaster

      @conkid– You want it readable in the revisions page, or to display in your theme?

    • #5433
      conkid
      Member

      In the revisions page

    • #5443
      Steve
      Keymaster

      @conkid– WordPress saves term data by ID, not slug or name. So if you want it saved, that can’t change. This a limit on WordPress, not Piklist. You can create another field, that pulls the term ID’s, converts them to slug or name, and save that. It may be a little tricky to implement.

    • #5463
      Steve
      Keymaster

      @conkid– I just emailed you back your code. The reason the taxonomy data wasn’t showing on the list table, is because you weren’t really saving the taxonomy data as taxonomy data… you were saving it as post_meta.

      When using a taxonomy field on any page except editing terms (i.e. editing a post), you need to do two things:
      1) The field name must be the exact name of the taxonomy.
      2) You must set ‘scope’ => ‘taxonomy’

      Hope this helps.

Viewing 8 reply threads
  • You must be logged in to reply to this topic.