Support

Account

Home Forums Feature Requests Displaying Car Prices from Page Listings on Post Car Pages Using ACF

Unread

Displaying Car Prices from Page Listings on Post Car Pages Using ACF

  • I’ve introduced a new post type in WordPress named “car” where I showcase the specifications of various cars. I’ve extensively utilized Advanced Custom Fields (ACF) with numerous fields for all the specifications and details.

    In the page-price.php template:
    I’ve additionally created a new group field for the car prices on a page where I list all the cars and set their prices. Now, I aim to input the identifier for each car in that list to display the prices on the “car” post type page.

    My objective is to manage and update price changes for each car on a single page, ensuring that the modifications reflect across all different car specification pages. I’m also looking to avoid the hassle of individually editing all posts related to the 200 cars.

    Will this potentially lead to slow loading of the car specification pages?
    How can I display the price of each car on the single post page of each car?
    <div class="car-price">
    <?php
    $current_car_id = get_the_ID(); // this car id

    if (have_rows('pr-price')):
    while (have_rows('pr-price')): the_row();
    if (have_rows('pr-p-list')) :
    while (have_rows('pr-p-list')): the_row();
    $car_id_in_price_table = get_sub_field('pr-p-i-id');
    if ($car_id_in_price_table == $current_car_id) :
    // show price of car
    echo get_sub_field('pr-p-i-co');
    endif;
    endwhile;
    endif;
    endwhile;
    endif;
    ?>
    </div>

    I’ve used this code in my single-car.php, but it’s not functioning. How should I proceed to resolve this?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.