I have a “static page” (without WordPress, locally) which uses isotope.js in a section to filter the elements showing in this page, I use classes as a sort of “tag” to filter the items.

However now I’m adding WordPress to this site, and these items need to be custom post types, and this classes need to be added by the user and I thought to do so with custom fields. Is something like this possible? As of right now what I have doesn’t seem to work:

// ACF - Search Field Variables
$comprar_alquilar   = get_field("comprar_alquilar");
$tipo               = get_field("tipo");
$donde              = get_field("donde");

                               <?php

                                    $args = array(
                                            "post_type" => "piso"
                                    );
                                    $the_query = new WP_Query( $args );

                                ?>

                                <?php if( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>

                                    <div class="pisos-grid-item-wrap <?php echo $comprar_alquilar ?>; <?php echo $tipo ?>; <?php echo $donde ?>;">
                                     <a href="<?php the_permalink(); ?>"> <img src="<?php the_post_thumbnail( 'post-thumbnail', array('width'=>'270')  );?>" alt="">  </a>
                                        <h1> <?php echo $precio ?> € </h1>
                                        <h2> <?php the_title(); ?> </h2>
                                        <h3> <?php echo $donde ?> </h3>
                                    </div>

                                <?php endwhile; endif; ?>

This is basically my custom post types loop, as you can see I’m trying to echo out my ACF variables as a class but to no avail:

<div class="pisos-grid-item-wrap <?php echo $comprar_alquilar ?>; <?php echo $tipo ?>; <?php echo $donde ?>;">

Read more here: Custom Field as Custom Post type element class


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: