Updating ACF fields in portfolio posts

Helllo I am trying to update a field in a portfolio post but I am not sure if I am referencing the portfolios properly

// Update the "portfolio_sort" field of related portfolio posts
            $portfolio_args = array(
                'post_type'      => 'portfolio_item', // Adjust the post type as needed
                'posts_per_page' => -1,
                'tax_query'      => array(
                    array(
                        'taxonomy' => 'client',
                        'field'    => 'term_id',
                        'terms'    => $term->term_id,
                    ),
                ),
            );

            $portfolio_posts = get_posts( $portfolio_args );

            foreach ( $portfolio_posts as $portfolio_post ) {
                // Update the ACF date field "portfolio_sort" with the latest published date
                update_field( 'portfolio_sort', $latest_published_date, $portfolio_post->ID );
            }
        }

are portfolios post type portfolio or portfolio item ?

Hey @wicara,

Thanks for reaching out!

If you are using the default Portfolio from our theme, the post_type slug is x-portfolio. You can check it from the link /wp-admin/edit.php?post_type=x-portfolio.

Hope that helps.

Thank you appreciate it

Hey @wicara,

You’re most welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.