Forum Replies Created
-
AuthorPosts
-
JasonKeymaster🙂
JasonKeymasterThis works:
add_filter('wpseo_metabox_prio', 'move_yoast_metabox_to_bottom'); function move_yoast_metabox_to_bottom() { return 'low'; }That’s a filter that was added by Yoast for exactly this purpose, so it’s safe to use.
Enjoy! 🙂
JasonKeymasterFixed a bug for the case of an empty image field and made a gist for this for easier revisions: https://gist.github.com/JasonTheAdams/d40351ecf5bca8a7e7f4#file-parse_piklist_array
JasonKeymasterI added support for the uploads field and nested groups. The resulting element will inherit the array of image ids if it’s an image, otherwise it will recursively work through the groups.
function parse_piklist_array($array) { if ( empty($array) ) return array(); $keys = array_keys($array[0]); if ( empty($keys) ) return array(); $results = $values = array(); $count = count($array[0][$keys[0]]); for ($index = 0; $index < $count; $index++) { foreach($keys as $key_index => $key) { $value = $array[0][$key][$index]; if ( is_array($value) && !isset($value[0][0]) ) $values[$key] = parse_piklist_array($value); else $values[$key] = $value; } $results[] = $values; } return $results; }
JasonKeymasterHmm.. apparently the $data parameter doesn’t hold unsupported comment data. Perhaps it’d be useful to to support a “custom” line, or else permit extra comment data.
JasonKeymasterAmended the above code to avoid some php warnings:
add_action('init', 'remove_unused_editors'); function remove_unused_editors() { if ( !isset($_GET['post']) && !isset($_GET['post_ID']) ) return; $post_id = ( isset($_GET['post']) ) ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE); switch ($template_file) { case 'page-product-overview.php': remove_post_type_support('page', 'editor'); } }
JasonKeymasterI tried using a radio instead.. no dice. But switching to a Select did the trick.
JasonKeymasterAnother issue I’m having in the same group: After I add a second instance of the group and save the settings, the checkbox field no longer shows up once the page reloads. Only the checkbox field and only for the non-first fields.
JasonKeymasterHi Steve!
Good call on the first, and good to know for the second.
I’m not sure if I should make a new thread for this, but it pertains to the context. I added another group field, slug, and gave it the field value “slug”. But, above the group is another field that has the same field value. I assumed that because the second slug was inside of a group it would recognize the difference. I believe it stores properly (that is it wouldn’t write to the same row), but apparently it doesn’t distinguish upon retrieval.
Keep rockin, Piklist!
JasonKeymasterHah! Sorry about that.. but thanks, Steve! 🙂
JasonKeymasterMaybe I’m wrong, but if the scope is post I believe the field has to be a column available to the wp_posts table (e.g. content, excerpt, etc.). Otherwise, if you omit the scope parameter (or use ‘post_meta’), it should save just fine to the wp_postmeta table.
JasonKeymasterCan you please paste the code you’re using to generate the field? I’ve found most bugs of this kind tend to come about from using unexpected field parameters.
JasonKeymasterFor those interested, I had a case where I wanted to hide the editor from only specific pages using a specific template. Here’s what I did:
add_action('init', 'remove_unused_editors'); function remove_unused_editors() { $post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'] ; $template_file = get_post_meta($post_id,'_wp_page_template',TRUE); switch ($template_file) { case 'page-about.php': case 'page-home.php': remove_post_type_support('page', 'editor'); } }
JasonKeymasterI’m trying to think through a context in which it would be advantageous to have a single post-relate field with multiple post types versus a field for each one. I mean, Piklist aside, you get one field per taxonomy.
@puppet – Is there a reason to merge them instead of splitting them into multiple fields?
JasonKeymasterPerfect! Thanks!
-
AuthorPosts