Tagged: checkbox, meta_key, meta_value, pre_get_posts, taxonomy
- This topic has 11 replies, 2 voices, and was last updated 6 years, 2 months ago by
Anthony.
-
AuthorPosts
-
-
December 2, 2015 at 6:52 pm #5191
AnthonyMemberI am trying to get a simple checkbox meta attached to a post. I am using this code:
<?php /* Title: Publish (Clearance) Post Type: post Capability: administrator */ piklist('field', array( 'type' => 'checkbox' ,'scope' => 'taxonomy' ,'field' => 'post_clearance' ,'label' => 'Cleared' ,'description' => 'Administrators & Editors can clear publication for edition.' ,'choices' => array( 'cleared' => 'Cleared' ) )); ?>Two things happen. One is that the meta box does successfully appear, but when I check it and hit update, it doesn’t save it. (Using version 0.9.9.6 beta)
Essentially using this simple one-option check box to act as a simple boolean function for a pre_get_post call through functions.php. This is what I have, but its not yielding any results of at the moment cause of the issue above.
function homepage_sticky_date_normalized( $query ) { if (is_home() || is_archive() && $query->is_main_query()) $query->set('ignore_sticky_posts', true); // don't stack sticky posts $query->set( 'meta_key', 'clearance' ); $query->set( 'meta_value', true ); // $query->set('post__not_in', $excludes); // $query->set('post__not_in', get_option('sticky_posts')); } add_action( 'pre_get_posts', 'homepage_sticky_date_normalized' );These additional
query-setskill the listing of my posts in the backend.$query->set( 'meta_key', 'clearance' ); $query->set( 'meta_value', true );So three problems. :-/
-
December 2, 2015 at 9:03 pm #5194
SteveKeymasterIs
post_clearancea taxonomy? -
December 2, 2015 at 9:33 pm #5198
AnthonyMemberI did set it as a taxonomy to start things off, yeah. Right now I am trying to figure out how to get the setting to stick at this point. Since every time I update the post it doesn’t save it…
I can see that my
query->setto ameta-keywas misguided. Any ideas as to why the setting won’t even stick? -
December 2, 2015 at 9:35 pm #5199
SteveKeymasterDoes it save if you disable this function,
homepage_sticky_date_normalized()? -
December 2, 2015 at 9:36 pm #5200
AnthonyMemberno it doesn’t.
-
December 2, 2015 at 9:40 pm #5201
SteveKeymasterIt saves for me. Feel free to zip up your plugin or theme and email to [email protected] Happy to take a look.
-
December 2, 2015 at 9:51 pm #5202
AnthonyMemberThis reply has been marked as private. -
December 2, 2015 at 9:56 pm #5203
AnthonyMemberThis reply has been marked as private. -
December 2, 2015 at 10:11 pm #5204
SteveKeymasterJust tested your theme and was able to reproduce. This is a bug that will be fixed in the next version of Piklist. You may want to change this to a select or radio.
-
December 2, 2015 at 10:51 pm #5205
-
December 7, 2015 at 12:07 pm #5245
SteveKeymasterI just tested and was able to reproduce. If I remove the taxonomy scope then it seems to work for me. Can you verify?
-
December 7, 2015 at 1:35 pm #5256
AnthonyMemberVerified.
-
-
AuthorPosts
- You must be logged in to reply to this topic.