Forum Replies Created

Viewing 15 posts - 256 through 270 (of 330 total)
  • Author
    Posts
  • Jason
    Keymaster

    But 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).

    Jason
    Keymaster

    You 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.

    in reply to: Intermittent Values Displaying #2290
    Jason
    Keymaster

    Just shot you the files. Screencast coming.

    in reply to: Group Fields no longer displaying stored values #2275
    Jason
    Keymaster

    Hey Steve, Marcus!

    That was it! Clearing the cache did the trick. Thanks for the tip!

    ~Jason

    in reply to: Can Piklist Enable Significant Customizing of List Tables? #2274
    Jason
    Keymaster

    Just 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:

    With those you can change/remove/add headings as you please and generate the content.

    in reply to: Is there a Settings Save hook? #2259
    Jason
    Keymaster

    Assuming I can return null without causing issues (I’ll make a patch if it breaks), that should do it!

    in reply to: Listing CPT posts in a metabox using Piklist #2238
    Jason
    Keymaster

    Hi 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! 🙂

    in reply to: Conditional to file field #2186
    Jason
    Keymaster

    As 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’ => ‘!=’.

    in reply to: New Conditional Bug… YAAAY! #2180
    Jason
    Keymaster

    I 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:

    in reply to: Getting index of Add More items while in the loop #2170
    Jason
    Keymaster

    Being 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!

    in reply to: How to perform custom validation #2164
    Jason
    Keymaster

    That’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!

    in reply to: Getting index of Add More items while in the loop #2163
    Jason
    Keymaster

    Hi 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.

    in reply to: Html validation not working #2162
    Jason
    Keymaster

    You 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.

    in reply to: How to perform custom validation #2152
    Jason
    Keymaster

    I 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?

    in reply to: Where did piklist_add_meta_box go? #2148
    Jason
    Keymaster

    Oh.. you did send me that. Oops! Thanks, again!

Viewing 15 posts - 256 through 270 (of 330 total)