Forum Replies Created
-
AuthorPosts
-
August 26, 2014 at 4:51 pm in reply to: Pulling data from custom field and use it in place of Title of Custom Post Type #2319
JasonKeymasterBut I’m honestly not sure what you’re trying to accomplish. If you need to correct the titles, you could always hop on PhpMyAdmin and fix it there (assuming you can get the title from somewhere else).
August 26, 2014 at 4:49 pm in reply to: Pulling data from custom field and use it in place of Title of Custom Post Type #2318
JasonKeymasterYou can apply to the WP_Post properties by setting the scope and field appropriately:
piklist('field', array) 'type' => 'text', 'field' => 'post_title', 'scope' => 'post', 'label' => 'Title' ));Notice that the scope is set to post, and the field is post_title.
JasonKeymasterJust shot you the files. Screencast coming.
JasonKeymasterHey Steve, Marcus!
That was it! Clearing the cache did the trick. Thanks for the tip!
~Jason
August 20, 2014 at 10:25 am in reply to: Can Piklist Enable Significant Customizing of List Tables? #2274
JasonKeymasterJust to be clear, are you talking about the “All Posts” screen but for custom post types?
If so, it’s really not difficult to do this without Piklist. Check out the following:
- http://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
- http://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_type_posts_columns
With those you can change/remove/add headings as you please and generate the content.
JasonKeymasterAssuming I can return null without causing issues (I’ll make a patch if it breaks), that should do it!
JasonKeymasterHi Ian!
I made a select field a while back for post-to-post relationships: https://gist.github.com/JasonTheAdams/342ad36e9e98269e81c8
The purpose of post-to-post relationships is to create the ability to reference a page/post in either direction. Let’s say I have a product post type and I decide I decide I want an faq post type as well (for an faq archive). I can then add a post-relate field to the faq post type for the products. At that point, when creating an faq post, I can select the corresponding product(s).
From that point on, I can retrieve the corresponding faq post from the product, or I can select all the product(s) from the faq. So if I wanted to show the first 3 questions/answers on the product page, no problem.
Hope this helps! 🙂
JasonKeymasterAs a side note, in the documentation in both places you show the compare element, you’re using != as a literal instead of a string. This would cause an error. It should be ‘compare’ => ‘!=’.
JasonKeymasterI just ran into a similar issue, but on top of it affecting every instance, mine also has the added bonus that if I select “Custom”, it makes the entire group disappear.
piklist('field', array( 'description' => 'Limit: 3 Sections', 'type' => 'group', 'field' => 'footer-widgets', 'label' => 'Footer Sections', 'add_more' => true, 'validate' => array( array( 'type' => 'limit', 'options' => array( 'min' => 1, 'max' => 3 ) ) ), 'fields' => array( array( 'type' => 'text', 'field' => 'title', 'label' => 'Title', 'columns' => 6 ), array( 'type' => 'textarea', 'field' => 'content', 'label' => 'Content', 'columns' => 12 ), array( 'type' => 'text', 'field' => 'link-text', 'label' => 'Link Text', 'columns' => 4 ), array( 'type' => 'radio', 'field' => 'link-type', 'label' => 'Link Type', 'value' => 'post', 'list' => false, 'choices' => array( 'post' => 'post/page', 'custom' => 'Custom' ) ), array( 'type' => 'text', 'field' => 'link-url', 'label' => 'Custom URL', 'conditions' => array( array( 'field' => 'footer-widgets:link-type', 'value' => array('custom') ) ) ), array( 'type' => 'select-post', 'field' => 'link-post-id', 'label' => 'Post to Link', 'options' => array( 'characters' => 30 ), 'conditions' => array( array( 'field' => 'footer-widgets:link-type', 'value' => array('post') ) ) ) ) ));And because animated gifs are fun:

JasonKeymasterBeing perfectly honest, I don’t use the piklist loop views as not to be limited by what Piklist exposes to the view loop. I prefer to parse the meta, and handle it myself from there. So I’d do something like this (as an example):
$list = ''; $faqs = parse_piklist_array(get_post_meta(get_the_ID(), 'faq', true)); foreach($faqs as $index => $faq) { $list .= "<li>$index: <span>{$faq['question']}</span> {$faq['answer']}</li>"; } $list = "<ul>$list</ul>";Of course it’d be great to use the Piklist loop as you’re intending, but if you need it now you can do something like that.
Hope this helps!
JasonKeymasterThat’s exactly what I ended up doing. Worked great!
I get the callback now. If it returns === true, then it’s valid; if it returns a string, that’s the error message. Might be a good idea to specify that in the docs. 😉
This can be closed. Thanks!
JasonKeymasterHi Ian!
Just because you mentioned the function I wrote, I wanted to let you know I just updated it (same gist). Use it like this:
$array = parse_piklist_array(get_post_meta($post_id, 'field-name', true));If that doesn’t work (after grabbing the latest code), I’d be curious what issue you’re having.
JasonKeymasterYou know, I actually went a different direction with this. I was providing a field for an embedded youtube video that would take the iframe html YouTube provides… but I really didn’t like the idea of having the user copy and paste that in, especially since I don’t know what options/size they’re selecting.
So what I did instead is write regex that takes either the full or short youtube url, and extracts the video id from the url. I then use that to build the iframe html myself.
I think you’re safe pulling the validation. For the most part content will be sanitized, not validated as html. Outside of this instance (which I didn’t like), I’ve never had a moment wherein I wanted the user entering html. Kind of goes against the philosophy of Piklist, I think.
For the record, though, I went into the Piklist code, grabbed the html regex, and it worked just fine elsewhere. I’m not sure what the problem was.
JasonKeymasterI just realized I was going about this all wrong. Oops! I have to add the validation first through the hook: https://piklist.com/user-guide/docs/piklist_validation_rules/
I guess I’m not understanding what the callback is for, then? At what point in the validation process is the callback called and for what purpose?
JasonKeymasterOh.. you did send me that. Oops! Thanks, again!
-
AuthorPosts