Tagged: 

Viewing 1 reply thread
  • Author
    Posts
    • #5315
      jordisanchez
      Member

      Hi there, newbie here. I’m falling in love with Piklist 😀

      I’m trying to create a condition based on a custom post type. I don’t know how many posts there are, so I’m creating an auxiliar array $models_array like this:

      $models_array = array();
      $materials = get_posts( array('orderby' => 'post_title','order' => 'asc','post_type' => 'materials'));
      foreach ($materials as $material) {
      	$models = get_post_meta( $material->ID, 'models' )[0]['model'];
      	array_push ($models_array,
      		array(
      			'type' => 'update'
      			,'value' => $material->ID
      			,'field' => 'material-cedit:models'
      			,'update' => $models
      		)
      	);
      }

      Is there any way to do something like this:

      'conditions' => array(
      	'relation' => 'or'
      	,$models_array[0]
      	,$models_array[1]
      	,$models_array[2]
      	,$models_array[3]
      )

      But without knowing how many elements are in the $models_array array?

    • #5331
      Steve
      Keymaster

      @jordisanchez– Welcome to the Piklist community!

      That should work if you format the array properly.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.