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

    You need to get the field in the $post loop. Something like this:

    <?php get_header(); ?>
    
    <section class="content">
    
    	<?php get_template_part('inc/page-title'); ?>
    	
           <div class="pad group">
    
    <div class="entry">	
    						<div class="entry-inner">
    							<?php the_content(); ?>
    							<?php wp_link_pages(array('before'=>'<div class="post-pages">'.__('Pages:','hueman'),'after'=>'</div>')); ?>
    						</div>
    						<div class="clear"></div>				
    					</div><!--/.entry-->
    		
    <?php
    
    $posts = get_posts(array(
    	'numberposts' => -1,
    	'meta_key' => 'elokuvat_k',
        'order'=> 'ASC',
        'orderby' => 'elokuvat_k'
    ));
    
    if($posts)
    {
    	echo '<ul>';
    
        $temporary_list = array();
    	foreach($posts as $post)
    	{
    		$film_names = get_field('elokuvat_k', $post->ID);
            $film_names_array = preg_split( '/\r\n|\r|\n/', $film_names );
            foreach($film_names_array as $film_name){
                $temporary_list[] = array('post_id' => $post->ID, 'film_name' => $film_name);
            }
    	}
        foreach( $temporary_list as $i => $row ) {
            $order[ $i ] = $row['film_name'];
        }
        array_multisort( $order, SORT_ASC, $temporary_list );
        
        foreach($temporary_list as $film_name){
            echo '<li><a href="' . get_permalink($film_name['post_id']) . '">' . $film_name['film_name'] . '</a></li>';
        }
        
    	echo '</ul>';
    }
    
    ?>
    
    	</div><!--/.pad-->
    	
    </section><!--/.content-->
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    If you don’t know how to modify it, please learn more about PHP here: http://www.w3schools.com/php/ or hire a developer to help you out with it. I recommend looking for one on https://studio.envato.com/ or https://www.upwork.com/.

    I hope this helps.