Home › Forums › Front-end Issues › Group Fields + custom post
Hi everyone, I have a difficulty I can’t visualize the fields within a group. I did a test with the fields outside the group and it works but when I enter the correct value I don’t display anything. here is the code. Thanks to all.
<?php
$args = array(
'post_type' => array('wine_code', 'page'),
'order' => 'ASC',
'posts_per_page' => -1,
);
// Eseguo la query
$the_query = new WP_Query($args);
// Conto gli elementi
$count = $the_query->post_count;
$output= (isset($_POST['submit']))?$_POST['input']:'';
?>
<?php
$categories = get_categories(); $count = count($categories);
foreach ($categories as $category) {}
?>
<p data-aos="fade" style="color:#fff;">Inserisci il codice riportato sulla bottiglia
<form method="post" style="width: 50%;margin: auto;" data-aos="fade">
<input type="text" class="form-control" name="input"/> <!-- thiss is where the user enters text -->
<input type="submit" class="btn btn-primary" name="submit" value="trova">
</form>
</section>
<!-- Type service-->
<section class="webpage__type-service type-service">
<?php
$first_query = new WP_Query( $args );
while ($first_query->have_posts()) : $first_query->the_post();
//the_title(); //echo the title
//the_content(); //echo the content
$post_id = get_the_ID(); // or use the post id if you already have it
$category_object = get_the_category($post_id);
$category_name = $category_object[0]->name;
$str = get_the_content();
$choices = explode("-",$str);
//var_dump($ctg);
//echo '' . $category_name . '
';
//foreach($choices as $key => $value){
//echo '' . $value . '
';}
$test = the_field('titolo_icona_1');
if (in_array($output, $choices)) {
if ($category_name == "2014") {
echo $test;
} elseif ($category_name == "2015") {
echo "Questa bottiglia è stata prodotta nel 2015";
}
}
endwhile;
wp_reset_query();
?>
Thanks!!
<?php
$args = array(
'post_type' => array('wine_code', 'page'),
'order' => 'ASC',
'posts_per_page' => -1,
);
// Eseguo la query
$the_query = new WP_Query($args);
// Conto gli elementi
$count = $the_query->post_count;
$output= (isset($_POST['submit']))?$_POST['input']:'';
?>
<?php
$categories = get_categories(); $count = count($categories);
foreach ($categories as $category) {}
?>
<p data-aos="fade" style="color:#fff;">Inserisci il codice riportato sulla bottiglia<p>
<form method="post" style="width: 50%;margin: auto;">
<input type="text" class="form-control" name="input"/> <!-- thiss is where the user enters text -->
<input type="submit" class="btn btn-primary" name="submit" value="submit">
</form>
</section>
<!-- Type service-->
<section class="webpage__type-service type-service">
<?php
$first_query = new WP_Query( $args );
while ($first_query->have_posts()) : $first_query->the_post();
//the_title(); //echo the title
//the_content(); //echo the content
$post_id = get_the_ID(); // or use the post id if you already have it
$category_object = get_the_category($post_id);
$category_name = $category_object[0]->name;
$str = get_the_content();
$choices = explode("-",$str);
//var_dump($ctg);
//echo '<p>' . $category_name . '</p>';
//foreach($choices as $key => $value){
//echo '<p>' . $value . '</p>';}
if (in_array($output, $choices)) {
if ($category_name == "2014") {
echo "<div class='container'>
<h2 class='type-service__heading heading' data-aos='fade'>Anno 2014</h2>
<div class='type-service__text' data-aos='fade'>We provide best solutions for your dream, still adapt your budget & still match twith requires about quality of project</div>
<ul class='type-service__list row'>
<li class='type-service__item col-12 col-md' data-aos='fade'>
<div class='type-service__item-icon type-service__item-icon--interior'>
</div>
<h3 class='type-service__item-heading'>kpiopiopi</h3>
<div class='type-service__item-text'>ghjghjghjgh</div>
</li>
<li class='type-service__item col-12 col-md' data-aos='fade'>
<div class='type-service__item-icon type-service__item-icon--interior'>
</div>
<h3 class='type-service__item-heading'>3wertgfthfg</h3>
<div class='type-service__item-text'>llhjgfdghj</div>
</li>
<li class='type-service__item col-12 col-md' data-aos='fade'>
<div class='type-service__item-icon type-service__item-icon--interior'>
</div>
<h3 class='type-service__item-heading'>khgfdfhjkl</h3>
<div class='type-service__item-text'>jhgfd</div>
</li>
</ul>
</div>";
} elseif ($category_name == "2015") {
echo "Questa bottiglia è stata prodotta nel 2015";
}
}
endwhile;
wp_reset_query();
?>
I would like to put in place of the random words the fields I created in the acf group. how is this possible?
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.