- This topic has 5 replies, 2 voices, and was last updated 1 year, 8 months ago by
Steve.
-
AuthorPosts
-
-
June 5, 2020 at 3:44 am #10677
guit4evaParticipantHi 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!
-
June 5, 2020 at 9:23 am #10678
SteveKeymasterYou’re removing custom fields from Pages, not Posts.
Instead of
remove_post_type_support('page', 'custom-fields');, useremove_post_type_support('post', 'custom-fields'); -
June 5, 2020 at 11:57 am #10679
guit4evaParticipantHi 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.
-
June 5, 2020 at 12:39 pm #10680
SteveKeymasterA 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/
-
June 5, 2020 at 1:18 pm #10681
guit4evaParticipantAh, Gutenberg was the issue! Yes, solved! Thanks so much for your help, much appreciated indeed! 🙂
-
June 5, 2020 at 1:22 pm #10682
SteveKeymasterYou’re welcome!
-
-
AuthorPosts
- The topic ‘Custom Field values not saving’ is closed to new replies.