Support

Account

Home Forums Front-end Issues get the feature img from post objects Reply To: get the feature img from post objects

  • Hi @astrixoblix, it works.
    Thank u and @elliot. And I wanna go farther. As the image shown in my first post, I want to show 3 related produces. Now I repeat the code 3 times.

    $related_1 = 
    ...
    $related_2 = 
    ...
    $related_3 = 
    ...

    is it stupid? Any better idea?

    Here are the codes generated by ACF:

    if(function_exists("register_field_group"))
    {
    	register_field_group(array (
    		'id' => 'acf_releated-products',
    		'title' => 'Releated Products',
    		'fields' => array (
    			array (
    				'key' => 'field_5296d411901eb',
    				'label' => '1st related product',
    				'name' => '1_related_product',
    				'type' => 'post_object',
    				'post_type' => array (
    					0 => 'product',
    				),
    				'taxonomy' => array (
    					0 => 'product_category:213',
    				),
    				'allow_null' => 1,
    				'multiple' => 0,
    			),
    			array (
    				'key' => 'field_5296d53cf9d3e',
    				'label' => '2nd related product',
    				'name' => '2_related_product',
    				'type' => 'post_object',
    				'post_type' => array (
    					0 => 'product',
    				),
    				'taxonomy' => array (
    					0 => 'product_category:213',
    				),
    				'allow_null' => 1,
    				'multiple' => 0,
    			)
    ...