Forum Replies Created
-
AuthorPosts
-
SteveKeymasterDid you ever figure this out?
SteveKeymasterYou’re very welcome! Happy to help.
If you have a few minutes we’d appreciate if you could leave a quick review on Piklist. It really motivates us and helps the project: https://wordpress.org/support/plugin/piklist/reviews/
SteveKeymasterThe
0key is where the ID is stored.
Update this:
$meal_chef_image = wp_get_attachment_image_src($meal_chef[‘chef_image’], ‘medium’);To this (add [0]):
$meal_chef_image = wp_get_attachment_image_src($meal_chef[‘chef_image’][0], ‘medium’);it’s always a good idea to output your data arrays so you can verify.
SteveKeymaster@rashedul007– Welcome to the Piklist Community!
If you just output
$meal_chef[‘chef_image’], what so do you get?
SteveKeymaster@bevislw– Welcome to the Piklist Community!
Here are a few options:
1. Many developers choose to save the data normally and then convert it to uppercase on output. For that you can use the PHP functionstrtoupper: https://www.w3schools.com/php/func_string_strtoupper.asp2. To Validate I would recommend using a callback function with
strtoupper. Something like this should work:function my_check_uppercase($index, $value, $options, $field, $fields) { return $value === strtoupper($value) ? true : 'contains lowercase letters.'; }Using the callback is documented here: https://piklist.github.io/docs/actions-filters/filters/piklist_validation_rules/
3. If you want to convert the data on save you should use a Sanitization rule. Validation rules are true/false, where Sanitization rules can change your data. You can also use the
strtoupperfunction to convert your data. Here are docs on Sanitization rules: https://piklist.github.io/docs/actions-filters/filters/piklist_sanitization_rules/Let me know if any of these worked for you.
SteveKeymasterWhen creating a new post set
'object_id' => nullon all your fields
SteveKeymasterIt looks like you are trying to load content.html, which won’t work. Shortcodes need to be in PHP files.
You may want to try the “Dynamic Bootstrap Modal with External URL” solution here: https://www.codexworld.com/bootstrap-modal-dynamic-content-jquery-ajax-php-mysql/
With something like
<a href="javascript:void(0);" data-href="content.html?id=1" class="openPopup">About Us</a>, andidis the ID of the post you want to edit.
SteveKeymasterA few good ideas are listed here: https://www.codexworld.com/bootstrap-modal-dynamic-content-jquery-ajax-php-mysql/
SteveKeymasterAbsolutely! I’m not sure how you want to pass the data to your modal, but for example if you didn’t have a modal:
1. Create the links your user would click on like this, where the
post_idis the id of the post to edit:https://mydomain.com/edit/?id=5
2. In your Piklist form code you can add this before your field code:$post_id = isset($_GET['id']) ? $_GET['id'] : null;. This would grab the query parameter.
3. Then pass it to the Piklist fieldpiklist('field', array( 'type' => 'text' ,'scope' => 'post' ,'field' => 'post_title' ,'label' => 'Post Title' ,'required' => true ,'object_id' => $post_id ));Again, you will need to figure out how to do something similar with JS for the modal.
Does that make sense?
SteveKeymasterSomehow you’re going to have to grab the post ID from the link in your CPT list and pass it to the Piklist
object_idparameter like this:piklist('field', array( 'type' => 'text' ,'scope' => 'post' ,'field' => 'post_title' ,'label' => 'Post Title' ,'required' => true ,'object_id' => $post_id ));
SteveKeymasterWhat exactly are you trying to do?
SteveKeymaster@pozzerfield– Welcome to the Piklist Community!
You can easily embed a Piklist form in a modal. You would create the form as you normally would with Piklist, and then use the
piklist_formshortcode to render the form in your modal code. Here’s a tutorial to get you started: https://piklist.github.io/docs/tutorials/forms/understanding-front-end-forms/Remember, when using a shortcode in a PHP file you need to echo
do_shortcode. Here’s some more information: https://css-tricks.com/snippets/wordpress/shortcode-in-a-template/
SteveKeymasterIf you have the time, feel free to leave a review on WordPress.org. It really helps the project. Thanks!
SteveKeymasterThe reason you would include
'hide_meta_box' => trueand create your own Piklist field for your taxonomy is if you didn’t want to use the default WordPress UI for your Taxonomy terms.You could use Chosen or Select2 to add some cool functionality.
Instead of checkboxes you could use Radio Buttons or a Select field.
Or maybe you want to group your taxonomy terms by their parent.
With Piklist you don’t have to limit yourself to the default WordPress UI. You can easily change it, and still save your data normally.
SteveKeymasterAh… The reason the metabox wasn’t showing up is because you have this Piklist parameter set
,'hide_meta_box' => true, which hides the meta box: https://piklist.github.io/docs/actions-filters/filters/piklist_taxonomies/#hide_meta_box -
AuthorPosts