Support

Account

Home Forums Backend Issues (wp-admin) Can I use the text area to generate multiple meta values? Reply To: Can I use the text area to generate multiple meta values?

  • Hi @vierastalo

    For something like this, you need to split the entries and then save it to a temporary variable like this:

    $temporary_list = array();
    foreach($posts as $post){
        $film_names = get_field('elokuvat_k', $post->ID);
        $film_names_array = preg_split( '/\r\n|\r|\n/', $string );
        foreach($film_names_array as $film_name){
            $temporary_list[] = array('post_id' => $post->ID, 'film_name' => $film_name);
        }
    }

    After that you need to sort the array using array_multisort() function like sorting a repeater.

    foreach( $temporary_list as $i => $row ) {
    	$order[ $i ] = $row['film_name'];
    }
    
    array_multisort( $order, SORT_ASC, $temporary_list );

    Then you can loop the $temporary_list variable to show the entries.

    I hope this makes sense.