Home › Forums › ACF PRO › Echo ShortCode with Post ID › Reply To: Echo ShortCode with Post ID
Hi John, Thank you for quick response. I just checked. I actually Used this method before and it didn’t work. That is the reason I converted ACF field as POST ID instead of OBJECT to bring data ID into Shortcode
// with get_field result at below //
Warning: Array to string conversion in C:path/\style-1.php on line 284
Technically I have two post
Parts added into CARS and Cars shown in PARTS
I try to show ANOTHER PARTS inside Viewed part from assigned CAR brand with biderctional POST session in php
let say The Car is Pontiac and i add three body paint bucket (yellow-green-white)
When i enter Green paint post(PART.php) , poıntiac shown Added car that pontiac
When i enter pontiac post (CAR.PHP) green paint shown
But I want to fetch data from CAR fields that realted directly inside PARTS to show another colors that added inside PONTIAC
technically I reach first the CAR from PART-Template and i checked other parts that added in customfield in CAR name is car_parts
so post IDS must fetch from CAR with FOREACH and setup_postdata
Code is like that in singe_part.php
<?php if( $car): ?>
<?php foreach( $car as $post ):
// Setup this post for WP functions (variable must be named $post).
// so now process in CAR part and check data in parts_car field
from CAR post //
<?php $assigned_parts_from_car_post= get_field(‘parts_car’, $post); ?>
<?php echo do_shortcode(‘ [car-parts-1 items_number=”” external_link=”1″ category=”” items_id=”‘.$assigned_parts_from_car_post.'” columns=”4″ order=”ASC” orderby=”name” title=”Compatible Parts from CAR POST”]’); ?>
<?php endforeach; ?>
goes Array. If i use POST ID and the field it echo the id’s that acf works correctly but if i use get_field, it goes ARRAY
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
🚨 The 2023 ACF Annual Survey closes tomorrow! This is your last chance to complete the survey and help guide the evolution of ACF. https://t.co/0cgr9ZFOJ5— Advanced Custom Fields (@wp_acf) May 18, 2023
© 2023 Advanced Custom Fields.