Support

Account

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
    Array

    [download_btn url=”Array”]

    // #####

    Technically I have two post

    CAR
    PART

    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

    $car= get_field(‘parts_car’);
    <?php if( $car): ?>

    <?php foreach( $car as $post ):
    // Setup this post for WP functions (variable must be named $post).
    setup_postdata($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