• Hello Steve,

    First of all thanks for this great flexible and powerful plugin. I am very happy with it!

    I have an issue regarding post relations.

    This code (source: https://piklist.com/user-guide/docs/fields/post-post-relationships/) works OK – it DOES record the post relation:

    
      piklist('field', array(
        'type' => 'post-relate'
        ,'scope' => 'post'
        ,'template' => 'field'
      ));
    

    However, this code (source: piklist.0.9.9.9\piklist\add-ons\piklist-demos\parts\meta-boxes\field-relate.php) does NOT work OK (for me) – it does NOT record the post relation:

    
      piklist('field', array(
        'type' => 'checkbox'
        ,'field' => '_' . piklist::$prefix . 'relate_post'
        ,'label' => __('Relate Posts', 'piklist-demo')
        ,'choices' => piklist(
          get_posts(array(
            'post_type' => 'post'
            ,'numberposts' => -1
            ,'orderby' => 'title'
            ,'order' => 'ASC'
          ))
          ,array('ID', 'post_title')
        )
        ,'relate' => array(
          'scope' => 'post'
        )
      ));
    

    I suspect it has someting to do with ,'field' => '_' . piklist::$prefix . 'relate_post'. And, more specifically with piklist::$prefix.

    My specific code – that does NOT record the post relation:

    
      piklist('field', array(
        'type' => 'checkbox'
        ,'field' => '_' . piklist::$prefix . 'relate_post'
        ,'label' => __('Relate Posts', 'piklist-demo')
        ,'choices' => piklist(
          get_posts(array(
            'post_type' => 'ventizo_hypothesis'
            ,'numberposts' => -1
            ,'orderby' => 'title'
            ,'order' => 'ASC'
          ))
          ,array('ID', 'post_title')
        )
        ,'relate' => array(
          'scope' => 'ventizo_hypothesis'
        )
      ));
    

    Please your help. Thanks and regards, Henk

    • This topic was modified 7 years, 2 months ago by Henk Verlinde. Reason: Added correct code notation
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Henk Verlinde

    (@ve6304)

    Digging deeper, I learned that the data is stored in either the posts table or the postmeta table.

    So, when I changed 'scope' => 'ventizo_hypothesis' to 'scope' => 'post' it does work OK.

    • This reply was modified 7 years, 2 months ago by Henk Verlinde. Reason: Update code formatting
    Plugin Author Steve Bruner

    (@sbruner)

    Hi Henk– Thank you for using Piklist!

    In “most” (not always) cases the scope refers the table you want to save to. So “ventizo_hypothesis” wouldn’t work.

    Did changing to “post” work for you?

    Steve

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post relation NOT recorded’ is closed to new replies.