Skip to content

Instantly share code, notes, and snippets.

@yuriy-yarvinen
Created March 20, 2019 07:54
Show Gist options
  • Save yuriy-yarvinen/96b7c9a1a783d119bda23f1dccfbca48 to your computer and use it in GitHub Desktop.
Save yuriy-yarvinen/96b7c9a1a783d119bda23f1dccfbca48 to your computer and use it in GitHub Desktop.
wp fields conection
<?
$id = get_the_ID();
$posts = get_posts( array('post_type'=>'postTypeName','numberposts' => 500,) );
$i=0;
foreach( $posts as $post ){
$fields = get_field('fieldName',$post->ID);
if($fields){
foreach ($fields as $field) {
if($id == $field->ID){?>
<?php $img_team = get_field('image'); ?>
<div class="team">
<div class="specialists-wrapper-services">
<a href="<?php the_permalink() ?>">
<div class="specialist">
<div class="img">
<img src="<?=$img_team['url']; ?>" alt="<?=$img_team['alt']; ?>" />
</div>
<div class="text">
<span class="fio"><?php the_title(); ?></span>
<span class="dolzhnost"><?php the_field('post'); ?></span>
</div>
</div>
</a>
</div>
</div>
<?$i++;}
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment