Viewing 5 reply threads
  • Author
    Posts
    • #10677
      guit4eva
      Participant

      Hi there,

      I have added custom fields to the default type ‘post’ via:

      <?php
      /*
      Title: Post Extra
      Post Type: post
       */
      piklist('field', array(
          'type' => 'text'
          , 'field' => '1_product_price'
          , 'label' => 'Product Price'
          , 'attributes' => array(
              'class' => 'text',
          ),
      ));

      and then added the following via a custom plugin (using Oxygen builder, so no functions.php):

      function my_custom_init()
      {
          remove_post_type_support('page', 'custom-fields');
      }
      add_action('init', 'my_custom_init');

      However, the values in the fields won’t save properly (ie, disappear on page refresh after saving). This is only for the type ‘post’. They save correctly on custom post types created with Piklist.

      Any assistance would be highly appreciated!

    • #10678
      Steve
      Keymaster

      You’re removing custom fields from Pages, not Posts.

      Instead of remove_post_type_support('page', 'custom-fields');, use remove_post_type_support('post', 'custom-fields');

    • #10679
      guit4eva
      Participant

      Hi there Steve,

      Apologies for that, I posted the wrong code (while troubleshooting). The code I have is in fact ‘post’:

      function my_custom_init()
      {
          remove_post_type_support('post', 'custom-fields');
      }
      add_action('init', 'my_custom_init');

      Unfortunately it’s still not working though.

    • #10680
      Steve
      Keymaster

      A few things:
      1) Piklist doesn’t work with Gutenberg yet. So, if you’re using WordPress 5.0+ you should use the Classic Editor plugin for now: https://wordpress.org/plugins/classic-editor/

      2) You should also make sure Custom Fields are really gone. Check the “Screen Options” tab and make sure they are not listed there: https://www.wpbeginner.com/glossary/screen-options/

    • #10681
      guit4eva
      Participant

      Ah, Gutenberg was the issue! Yes, solved! Thanks so much for your help, much appreciated indeed! 🙂

    • #10682
      Steve
      Keymaster

      You’re welcome!

Viewing 5 reply threads
  • The topic ‘Custom Field values not saving’ is closed to new replies.