Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #297748

    Hi,
    I need to display a list of related post types to the current portfolio item.
    I use ACF to build relation between portfolio item and post types.
    I have added related post-types to current portfolio item.
    I have edited /config-templatebuilder/avia-shortcodes/portfolio.php file adding:

    Basic loop (with setup_postdata):

    $postx = get_field('your_business_product_items');
    if( $postx ):
      $output .="	  <ul>";
         foreach( $postx as $post): // variable must be called $post (IMPORTANT) 
             setup_postdata($post); 
            $output .="	<li>";
    			$output .="	<a href=";
    			the_permalink(); 
    			$output .=">";
    			the_title(); 
    			$output .="	</a>";
                $output .="	<span>Custom field from $post:";
    			the_field('author');
    			$output .="	</span>";
            $output .="	</li>";
         endforeach; 
        $output .="	</ul>";
         wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly 
     endif; 
    

    or basic loop (without setup_postdata)

    
     
    $postz = get_field('your_business_product_items');
     if( $postz ): 
     	$output .="<ul>";
    	 foreach( $postz as $p ): 
    $output .="	    <li>";
    	    	$output .="<a href='";
    			echo get_permalink( $p->ID ); 
    			
    			$output .="'>";
    			
    			echo get_the_title( $p->ID );
    			$output .="</a>";
    	    	
    			$output .="<span>Custom field from"; 
    			
    			the_field('author', $p->ID);
    			
    			$output .="</span> </li>";
    	 endforeach; 
    	$output .="</ul>";
     endif;

    But nothing appears.
    Anyone tried to do this?

    I display portfolio as a preview on one-page style Enfold.

    Thanks.

    #297810

    Hey motylanogha!

    No, we didn’t try this and we can’t provide support for the ACF plugin. I’ll leave this thread open in case a user already added an ACF code snippet to the theme code.

    Regards,
    Peter

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.