Support

Account

Forum Replies Created

  • This fixed it:

    foreach ($all_posts as $p):
    		$p->acf_fields = $all_acf_fields[$x];
    		//array_push($all_posts, $p);
    		$x++;
    	endforeach;

    Thanx again for your help!!!

  • I know that, at the end of your code, in this loop, is where things seem to get doubled up:

    	foreach ($all_posts as $p):
    		$p->acf_fields = $all_acf_fields[$x];
    		array_push($all_posts, $p);
    		    $x++;
    	endforeach;

    If I comment that out, and print $all_posts or $all_acf_fields, it shows the right number of arrays, ie, one array for each post

  • It’s weird, even if I delete all ACF fields from WP Admin area, and clean all ACF data from post_meta table in the DB, and all post data from wp_posts, except for the two published posts, I still get 4 arrays…

    If I add another post, I get 6 arrays, etc.

    Not sure where the code you’ve provided loops twice through each post.

    Thanx again for your help!!!

    Mark

  • Again, thanx so much for the help here.

    This almost does it – but for some reason, the code is generating four main arrays, but I only have two posts in my database. There should only be 2 WP_Post Object arrays, right? Here’s the output I got:

    Array
    (
        [0] => WP_Post Object
            (
                [ID] => 194
                [post_author] => 2
                [post_date] => 2019-03-01 16:29:16
                [post_date_gmt] => 2019-03-01 16:29:16
                [post_content] => My Neighbor's house - sweet yard, Victorian feng shui
                [post_title] => 2150 Lafayette Street Denver, 80205
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => 2150-lafayette-street-denver-80205
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2019-03-01 16:29:16
                [post_modified_gmt] => 2019-03-01 16:29:16
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => https://locatedenver.com/?p=194
                [menu_order] => 0
                [post_type] => post
                [post_mime_type] => 
                [comment_count] => 0
                [filter] => raw
                [acf_fields] => Array
                    (
                        [call] => No
                        [hot] => Yes
                    )
    
            )
    
        [1] => WP_Post Object
            (
                [ID] => 188
                [post_author] => 2
                [post_date] => 2019-03-01 16:21:50
                [post_date_gmt] => 2019-03-01 16:21:50
                [post_content] => My house, tiny back yard, super loud, bonsai trees, shitty grass
                [post_title] => 2144 Lafayette Street Denver, 80205
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => 2144-lafayette-street-denver-80205
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2019-03-01 16:26:01
                [post_modified_gmt] => 2019-03-01 16:26:01
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => https://locatedenver.com/?p=188
                [menu_order] => 0
                [post_type] => post
                [post_mime_type] => 
                [comment_count] => 0
                [filter] => raw
                [acf_fields] => Array
                    (
                        [call] => Yes
                        [hot] => Yes
                    )
    
            )
    
        [2] => WP_Post Object
            (
                [ID] => 194
                [post_author] => 2
                [post_date] => 2019-03-01 16:29:16
                [post_date_gmt] => 2019-03-01 16:29:16
                [post_content] => My Neighbor's house - sweet yard, Victorian feng shui
                [post_title] => 2150 Lafayette Street Denver, 80205
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => 2150-lafayette-street-denver-80205
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2019-03-01 16:29:16
                [post_modified_gmt] => 2019-03-01 16:29:16
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => https://locatedenver.com/?p=194
                [menu_order] => 0
                [post_type] => post
                [post_mime_type] => 
                [comment_count] => 0
                [filter] => raw
                [acf_fields] => Array
                    (
                        [call] => No
                        [hot] => Yes
                    )
    
            )
    
        [3] => WP_Post Object
            (
                [ID] => 188
                [post_author] => 2
                [post_date] => 2019-03-01 16:21:50
                [post_date_gmt] => 2019-03-01 16:21:50
                [post_content] => My house, tiny back yard, super loud, bonsai trees, shitty grass
                [post_title] => 2144 Lafayette Street Denver, 80205
                [post_excerpt] => 
                [post_status] => publish
                [comment_status] => open
                [ping_status] => open
                [post_password] => 
                [post_name] => 2144-lafayette-street-denver-80205
                [to_ping] => 
                [pinged] => 
                [post_modified] => 2019-03-01 16:26:01
                [post_modified_gmt] => 2019-03-01 16:26:01
                [post_content_filtered] => 
                [post_parent] => 0
                [guid] => https://locatedenver.com/?p=188
                [menu_order] => 0
                [post_type] => post
                [post_mime_type] => 
                [comment_count] => 0
                [filter] => raw
                [acf_fields] => Array
                    (
                        [call] => Yes
                        [hot] => Yes
                    )
    
            )
    
    )
  • So, you’re officially going above and beyond here. This is super helpful for a Joomla guy who knows next to nothing about the WP API.

    This works for all ACF field data, but I’m needing all ACF data, AND all the WP post data.

    Can you help me get that data into the array as well?

    Thanx so much for helping me with this.

    Mark

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