Support

Account

Home Forums Front-end Issues Change the Category Name with ACF inside the loop

Helping

Change the Category Name with ACF inside the loop

  • Hello!
    Could you, please, take a look at my problem?

    I have the following loop:

    <?php
        $args = array(
            'post_type' => 'cpt-a',
            'category_name' => 'my-category',
            'posts_per_page' => 99,
            'orderby' => 'date',
            'order' => 'ASC',
            'ignore_sticky_posts' => 1,
            'paged' => $paged);
                $loop = new WP_Query($args);
                if ($loop->have_posts()) :
                while ($loop->have_posts()) : $loop->the_post(); ?>
            
                    <div><?php echo get_the_content(); ?></div>
                    <span ><?php the_title(); ?></span>
    
    <?php endwhile;
    endif;
    wp_reset_postdata();
    ?>

    Is it possible to use a custom field (ACF) instead of “my-category”? I tried all the known options, but I could not find a working solution.

  • See documentation on querying post by custom fields.

    https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    Will need more information about what is not working

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.