Support

Account

Home Forums Front-end Issues Field is not automatically saved using update_field and wp_insert_post Reply To: Field is not automatically saved using update_field and wp_insert_post

  • I forgot my loop:

    <ul>
    		<?php query_posts(array( 'post_type' => 'arquivo' ) ); ?>
    		<?php while (have_posts()) : the_post(); ?>
    			<?php 
    			/*
    			 * Caso o campo Evento informado no Arquivo seja igual o evento
    			 * informado via URL, busca-se todos os arquivos (mídias) a esse Arquivo
    			 */ 
    			$_evento = get_field('evento');
    			if($_evento != ""){
    				
    				if($_evento == $eventoid){
    					$args = array(
    						'post_type' => 'attachment',
    						'numberposts' => null,
    						'post_status' => null,
    						'post_parent' => $post->ID
    					);
    					$attachments = get_posts($args);
    	
    					if(count($attachments) > 0 ){
    						foreach ($attachments as $file){
    							if ( $last_id = get_post_meta($file->ID, '_edit_last', true) ) {
    								$last_user = get_userdata($last_id);
    							}
    							else{
    								$last_user = get_userdata($file->post_author);
    							} ?>
    							<li>
    								<?php echo date("d.m.Y", strtotime($file->post_modified)); ?>
    								<span>Última alteração feira por: <?php echo $last_user->display_name;?></span> 
    								<a href="<?php echo $file->guid?>" title="<?php echo $file->post_title?>" target="_blank"><?php echo $file->post_title?></a>
    								<p><?php echo $file->post_content;?></p>
    							</li>
    							<?php }					
    					}
    				}
    			} ?>
    		<?php endwhile;?>
    	</ul>

    The post title, content… is show but the field ‘evento’ NOT.