Created
August 14, 2015 10:07
-
-
Save webgurus/3c6f2c98c3d698ffbe22 to your computer and use it in GitHub Desktop.
Function to return an ACF field value for all the subsites on a network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function getAllCRMIds() { | |
| global $wpdb; | |
| $blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != {$wpdb->blogid} AND site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' order by blog_id", ARRAY_A); | |
| // array_unshift($blogs, 1); /*Including parent blog in the array*/ | |
| $crm_to_blog = array(); | |
| foreach($blogs as $blog) { | |
| switch_to_blog( $blog[ 'blog_id' ] ); | |
| $posts = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}posts WHERE post_type='imoveis' AND post_status='publish' ORDER BY RAND() DESC LIMIT 10"); | |
| $count = 0; | |
| $CRMID=get_field('client_crm_id','option'); | |
| $crm_to_blog[] = array('crm_id'=> $CRMID, 'blog_id' =>$blog[ 'blog_id' ]); | |
| } | |
| print_r($crm_to_blog); | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment