How can i count the post added in relationship field. The relationship field is a plugin (http://www.advancedcustomfields.com/docs/field-types/relationship/)
In my admin i have a MetaBox i create to link the post from another post type to my posts. please see picture below in the link
Subtitle and Trailers
How can i get the number of post attach to the relationship field.
Ex: If the relationship field has 4 articles added in site in tabs i want to be able to get the number of articles
Ex: Trailers(1) - that are display in Front-end.
Something like this ( cinemagia.ro/filme/avatar-2-578279/ )
To retrive the post and display into my theme i use
<?php if(get_field('trailere_filme') != ""){foreach(get_field('trailere_filme') as $post_object): ?>
<div class="box-trailere">
<div class="trailer-img">
<a href="<?php echo get_permalink($post_object->ID); ?>" rel="bookmark" title="<?php printf(__('Trailer film %s', 'kubrick'), the_title_attribute('echo=0')); ?>">
<span class="tip"><?php echo get_field( 'tip', $post_object->ID ); ?></span>
<span class="trai-hov"></span>
<img src="http://img.youtube.com/vi/<?php echo get_field( 'trailer', $post_object->ID ); ?>/<?php echo get_field( 'img_trailer', $post_object->ID ); ?>" alt="Trailer <?php echo get_the_title($post_object->ID) ?>" title="Trailer <?php echo get_the_title($post_object->ID) ?>"></a>
<span class="duration"><?php echo get_field( 'time', $post_object->ID ); ?></span>
</div>
<span class="trailer-title"><a href="<?php echo get_permalink($post_object->ID); ?>" title="Trailer <?php echo get_the_title($post_object->ID) ?>"><?php echo get_the_title($post_object->ID) ?></a></span>
</div>
<?php endforeach;}else{?>
<div class="no-trailer">Acest film nu are trailer.</div>
<?php } ?>
And for tags related to post
in my hteme i use:
<?php
$orig_post = $post;
global $post;
$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'post_type'=> 'stiri',
'posts_per_page'=>1, // Number of related videos that will be shown.
'caller_get_posts'=>1
);}
$recentPosts = new WP_Query($args);
?>
<?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<div class="sidebar-titlu"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div>
<div class="sidebar-stiri">
<img src="/scripts/timthumb.php?src=<?php the_field('imagine_stire'); ?>&h=60&w=90&zc=1" alt="" title="<?php the_title(); ?>" />
<?php $excerpt = get_the_excerpt();echo string_limit_words($excerpt,30);?><a class="detalii" href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>">...detalii</a>
</div>
</div>
<?php endwhile; ?>
Thanks

relationship field? Where does it comes from? Where do you want to get its count, frontend, backend? Without context, it is impossible to answer... – brasofilo Jan 6 at 19:51edit, that you can use to edit the Q, add more information to it, so people can revert the downvote when you show more research efforts and care for the Q. While you are at it, read the documentation about the Relationship Field, apply it to your problem and modify the Q accordingly. Thanks! – brasofilo Jan 6 at 20:17