Home › Forums › General Issues › Use of get_field in multisite › Reply To: Use of get_field in multisite
Full script
function imoveisRede() {
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*/
$html = '<div>';
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;
foreach($posts as $post) {
$galerias = get_field('gallery', $post->ID);
$count++;
if ($count == 4) {
$html .= '<div class="clear"></div>';
}else {
$html .= '<div class="property span3" id="destaques">';
$html .='<div class="image">';
$html .='<div class="content">';
$html .='<a href="'.get_permalink($post->ID).'" title="'.$post->post_title.'"></a>';
$html .='<div class="content">';
$html .='<a href="'.the_permalink().'" title="'.$post->post_title.'"></a>';
if( $galerias ):
foreach( $galerias as $galeria ):
$html .='<li style="text-align:center !important;">';
$html .='<a href="'.get_permalink($post->ID).'" rel="lightbox">
<img src="'.$galeria['sizes']['large'].'" alt="'.$img_alt.'" /></a>';
$html .='</li>';
endforeach;
endif;
}
$html .='</div>';
}
$html .='</div>';
}
}
$html .= '</div>';
return $html;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.