Support

Account

Forum Replies Created

  • Thank you so much John for the feedback! I just discovered a simple way to solve this process.

    I created a variable in my wp-config.php file to determine what environment I’m in. If that value matched “local”, or “dev” or “prod”, that that determines which key field gets loaded.

    Its solving my problem so I believe this is resolved. Many thanks!

  • Solved my issue. I needed to also add

    $mproductowners = get_post_meta($post->ID,'product_owner',false);

    to properly get ACF data from my existing get_posts() loop. From here, I was able to traverse the array and output either larry, sally or bob.

  • I was able to upgrade the logic of my loop to be manipulated by ACF fields (yeaahh!!!), for example, I can filter the get_post loop by my meta_query of ACF data as shown below…

    //BUILD THE LOOP AND LOAD THE POSTS
    function ithub_exec_summary_landing_loop() {
    
    	//DEFINE OUTPUT VAR
    	$out = '';
    
    	//LOOP - GET AL EXECUTIVE SUMMARIES VIA GET_POSTS()
    	$args = array(
    		'numberposts' => -1,
    		'orderby' => 'modified',
    		'order'   => 'ASC',
    		'category_name' => 'executive-summary',
    		'meta_query' => array(
    			'relation' => 'OR',
    			array(
    				'key' => 'product_owner',
    				'value' => 'larry',
    				'compare' => 'LIKE'
    			),
    			array(
    			'key' => 'product_owner',
    			'value' => 'sally',
    			'compare' => 'LIKE'
    			),
    			array(
    			'key' => 'product_owner',
    			'value' => 'bob',
    			'compare' => 'LIKE'
    			)
    		)
    
    		);
    		$mExecSumPosts = get_posts($args);
    
    		//REFERENCE LOOP FOR PREVIEWING REVISIONS
    		if ($mExecSumPosts) {
    			foreach ($mExecSumPosts as $post):
    				setup_postdata($post);
    				//DEFINE LOOP VARS
    				$mtitle = $post->post_title;
    				$mpublisheddate = get_the_time('Y-m-d', $post->ID);
    				$mformateddate =  date("l F jS, Y",  strtotime($mpublisheddate));
    				//OUTPUT DATA
    				$out.= "<div class='row'>";
    				$out.= "<div class='col'>";
    				$out.= "<h3><a href='{$post->post_name}'>{$mtitle}</a> <span class='h5 text-secondary'>: Status Date of {$mpublisheddate} | </span></h3>";
    				$out.= "</div>";
    				$out.= "</div>";
    			endforeach;
    		}
    	return $out;
    }
    wp_reset_postdata();
    }

    …But! How can I output the product owner name (larry, sally, or bob) in this get_posts loop, for each post that is loaded? I have a feeling I may need to create a second get_posts() loop, but don’t know what that looks like from this point forward. Any help would be awesome!

  • This appears promising, but what if you are working with multiple field names and not just one? what if you have 8 fields that are multi select fields, out of 27 total fields that are other types?

  • @danielgc, Your simple style solution within the action admin_head, was all I needed. You can take things further by tracking down specific iframes on your posts and pages like so…

    add_action('admin_head', 'admin_styles');
    function admin_styles() {
    	?>
    	<style>
    		iframe[id^='wysiwyg-acf-field-favicon_'] {
    			min-height:40px;
    		}
    	</style>
    	<?php
    }
     ?>

    In my case, I’m targeting only the favicon fields on my WP admin pages, to have a height adjustment.

  • The Use of get_field_objects with the guidance of var_dump, helped me to prepare my php foreach loop they way I want it.. Thank you James!

Viewing 6 posts - 1 through 6 (of 6 total)