0

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 ?>;">
  • Is it filled out? or is it empty? If you put this into your php : highlight_string("<?php\n\$ACF-fields =\n" . var_export(get_fields(), true) . ";\n?>"); - Then you can see everything that is in your ACF fields for your post. – Stender May 18 '17 at 10:15
  • also - might need to get the fields inside your loop, else ACF won't know which post to look for the fields from – Stender May 18 '17 at 10:17
  • also - It seems that you are opening a php tag before your loop - Where is your php tags for ACF? – Stender May 18 '17 at 10:18
  • Sorry it's simply because I started copying there but it's there. Thank you for the feedback, I'll try your solutions in a bit. – Sergi May 18 '17 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.