Last active
June 9, 2020 15:06
-
-
Save xlawok/8d47e04ad9b2ddc812a919d2cceaf5c4 to your computer and use it in GitHub Desktop.
Wordpress PODS repeater and realationship - how to get in reapeater loop relationship field ID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$top_banner_items=pods_field( 'front_page_banner ', get_the_ID()); | |
foreach($top_banner_items as $item): | |
$query = "SELECT related_item_id FROM {$wpdb->prefix}podsrel where item_id={$item['id']} and field_id=153"; | |
$img_srcset = wp_get_attachment_image_srcset( $item['zdjcie'],'large'); | |
echo '<a href="'.get_category_link($wpdb->get_var($query)).'" title="'.get_the_title().'" class="product-image">'; | |
echo "<img class='' | |
sizes='(max-width: 991px) 100vw, 40vw' | |
srcset='".esc_attr($img_srcset)."'/>"; | |
var_dump($item); | |
echo "</a>"; | |
endforeach; | |
// from anwser from issue: | |
To get a relationship product category | |
taxonomy in a repeater field, you can try this: pods_field( | |
'repeater_field_pod_slug', 'id', 'field_name' ). In your case, assuming | |
your repeater field pod is named as page_banner and the field name for the | |
relationship field is product_category: | |
$top_banner_items= pods_field( 'front_page_banner', get_the_ID()); | |
foreach ( $top_banner_items as $item ) { | |
print_r( pods_field( 'page_banner', $item['id'], 'product_category') ); | |
echo '<br/>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment