Support

Account

Home Forums Front-end Issues Relationship is not working on front page

Solving

Relationship is not working on front page

  • Hi
    <?php

    $posts = get_field(‘major_city’);

    if( $posts ): ?>

      <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
      <?php setup_postdata($post); ?>

    • “><?php the_title(); ?>
      <span>Custom field from $post: <?php

        the_field();

      ?></span>

    • <?php endforeach; ?>

    <?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>

    i created a relationship with featured image
    its comes under the dashboard
    but it doesnt work on the front end

    and i used as taxonomy term to tour categories

    plzzzzzzzzzzzzzzz
    help me to find the solution

  • What field are you trying to get on the related post

    
    <span>Custom field from $post: <?php
    
        the_field();// no field name given
    
    ?></span> 
    
  • Relaional field with featured image
    am trying for

  • 
    <?php
    
    	$posts = get_field(‘major_city’);
    
    if( $posts ): ?>
    
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
        <?php setup_postdata($post); ?>
    
       <?php the_title(); ?>
        <span>Custom field from $post: <?php
            the_post_thumbnail();
    
        ?></span>
    
        <?php endforeach; ?> 
    
    <?php wp_reset_postdata(); // IMPORTANT – reset the $post object so the rest of the page works correctly ?>
    <?php endif; ?>
    
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.