Tagged: , ,

Viewing 12 reply threads
  • Author
    Posts
    • #1992

      Hello every one, i have this code

      piklist('field',array(
          'type' => 'group'
      ,'field' => 'muni'
      ,'label' => __('Datos del servicio')
      ,'position' => 'wrap',
          'columns' => 12,
          'fields' => array(
              array(
                  'type' => 'text',
                  'field' => 'ubicacion',
                  'label' => 'Ubicación',
                  'columns' => 12
              ),
              array(
                  'type' => 'select'
                  ,'field' => 'muni'
                  ,'label' => 'Seleccione un municipio'
                  ,'columns' => 12
                  ,'choices' => piklist(
                      get_posts(
                          array(
                             'numberposts' => 20,
                              'post_status' => 'any',
                              'post_type' => 'municipios',
                              'orderby' => 'DESC'
                          )
                      )
                      ,array(
                          'ID'
                          ,'post_title'
                      )
                  ),
                      'attributes' => array(
                          'cols' => 3,
                          'rows' => 3
                      ),
      
               ),
              array(
                  'type' => 'select',
                  'field' => 'tipo',
                  'label' => 'Tipo de Atractivo',
                  'columns' => 12,
                  'choices' => array(
                      'sitio' => 'Sitio Turístico',
                      'cenote' => 'Cenote / Gruta',
                      'iglesia' => 'Iglesia / Convento',
                      'hacienda' => 'Hacienda'
                  )
              )
      
          )
      ));

      and i want to filter by “municipio” but how can i ?, im using wp query 🙂

      thanks a lot!

    • #1993
      Steve
      Keymaster

      What do you mean you want to filter by ‘municipio’? On the front end? In your theme?

    • #1994

      Hello Steve, yep in my theme im using this code

       $args_sitios = array(
              'post_type' => 'sitios',
              'posts_per_page' => -1,
              'meta_query' => array(
                  array(
                      'key' => 'muni',
                      'value' => 68 ,
                      'type' => 'numeric',
                      'compare' => 'IN'
                  )
              )
          );

      but there is no results

    • #1995

      any one know how can i filter this “group” type of piklist? 🙁

    • #1996
      Steve
      Keymaster

      What are you trying to accomplish with the field you posted? What is that field supposed to do?

    • #1997

      i need to filter my cpt by the field named “muni” in the front end with wp query, but i dont know how

    • #1998
      Steve
      Keymaster

      If you look in your database, you will see how the data is saved, which is currently an array and won’t work for you.

      Remove the main field parameter and all your data should save individually:

      piklist('field',array(
       'type' => 'group'
      ,'field' => 'muni' // REMOVE THIS
      ,'label' => __('Datos del servicio')
      
    • #1999

      I need to do a search of all posts are within a selectable option element “muni” but piklist is a “group” then, as I do to get the post?

    • #2000

      the problem is that I have a very large data base, too many post, then I need to change each and every one of the posts in order to get that, there is a better way?

    • #2001
      Steve
      Keymaster

      try the field both ways. Enter data and save, and then check your database. You should see a difference.

    • #2002
      Steve
      Keymaster

      Unfortunately, no. Look in the database. Your data is being saved as an array, which you cannot filter. If you want to filter the data you need to remove the field parameter from the main group so each field is saved separately.

    • #2003

      delete the field, and the information has disappeared, which is not good, if I put the information back field, I guess that’s the structure I had in the beginning, but then it is not no way to do a search with the structure today, and I must change all post? : (

    • #2004
      Steve
      Keymaster

      @cegodai– Can you email us your full plugin with the Post Type registration? We should be able to write you a script to convert the data.

Viewing 12 reply threads
  • The topic ‘wp query group field in piklist’ is closed to new replies.