Tagged: ,

Viewing 6 reply threads
  • Author
    Posts
    • #6571
      mcmaster
      Member

      I have an event post type. Some events are small; others are annual events and warrant their own pages. So I have a select field for events that enables the user to choose the page associated with an event.

      I’ve done this before with post_meta and had no problem. But this time, because the events aren’t hierarchical, I decided to use post_parent to store the page ID. What I found is that I could set the post_parent to have a specific page value, but that I couldn’t set it to zero.

      When the value is stored in post_meta, there’s no problem setting it back to zero.

      Here’s the code:

      
      <?php
      /*
      Title: Page Test
      Description: select page for event
      Post Type: event
      Priority: high
      Order: 20
      */
      
      // get an array of page titles indexed by page IDs
      $default_page = array( 0 => '-- none --' );
      $choices = $default_page + piklist(
      	get_posts( array(
      		'post_type' => 'page',
      		'numberposts' => -1,
      		'orderby' => 'title',
      		'order' => 'ASC'
      	)),
      	array( 'ID', 'post_title' )
      );
      
      piklist('field', array(
      	'field' => 'event_page',
      	'type' => 'select',
      	'scope' => 'post_meta',
      	'label' => 'Event Page (stored in post_meta)',
      	'description' => 'If there is a special page for this event, select it here.',
      	'choices' => $choices,
      ));
      
      piklist('field', array(
      	'field' => 'post_parent',
      	'type' => 'select',
      	'scope' => 'post',
      	'label' => 'Event Page (stored in post_parent)',
      	'description' => 'If there is a special page for this event, select it here.',
      	'choices' => $choices,
      ));
      

      Not surprisingly, behavior is the same for radio buttons.

      HTH,
      Donna

    • #6572
      mcmaster
      Member

      p.s. Should have mentioned that I’m using Piklist 0.9.9.8

    • #6573
      Steve
      Keymaster

      What happens when you try to save “0”?

    • #6580
      mcmaster
      Member

      There’s no error message, but the value remains whatever it was before. I can change it to another non-zero value but not zero.

      I have the error isolated on a test site; would you like access to it?

    • #6581
      mcmaster
      Member
    • #6582
      Steve
      Keymaster

      @mcmaster– We were able to reproduce and will work on a fix.

    • #6585
      mcmaster
      Member

      Great, thanks!

      • #6587
        Steve
        Keymaster
        This reply has been marked as private.
Viewing 6 reply threads
  • You must be logged in to reply to this topic.