Home › Forums › Front-end Issues › Image shows int instead of string inside subgroup
hello friends
I have a main group of Department tab which shows on a department page
within which there are 6 subgroups Cardiology,Virologist,Eye specialist like so
and each of this has 4 fields ..heade,sub header,body text,image
here is the code,its basicallyy a jquery vertical tab
<div class="row">
<div class="col-lg-3">
<ul class="nav nav-tabs flex-column">
<li class="nav-item">
<a class="nav-link active show" data-toggle="tab" href="#tab-1">Cardiology</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-2">Virologist</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-3">Eye specialist</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-4">Pediatrics</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-5">Hepatology</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-6">Neurology</a>
</li>
</ul>
</div><!--col-lg-3-->
<?php
$Department_tab = get_field('department_tab');
$Cardiology = $Department_tab['cardiology'];
$Virology = $Department_tab['virologist'];
$Eye_Specialist = $Department_tab['eye_specialist'];
$Pediatrics = $Department_tab['pediatrics'];
$Hepatology = $Department_tab['hepatology'];
$Neurology = $Department_tab['neurology'];
?>
<div class="col-lg-9 mt-4 mt-lg-0">
<div class="tab-content">
<div class="tab-pane active show" id="tab-1">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-l">
<h3> <?php echo $Cardiology['header'];?></h3>
<p class="font-italic">
<?php var_dump($Cardiology); ?>
<?php echo $Cardiology['sub_header'];?></p>
<p><?php echo $Cardiology['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Cardiology['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-2">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Virology['header'];?></h3>
<p class="font-italic">
<?php var_dump($Virology); ?>
<?php echo $Virology['sub_header'];?></p>
<p><?php echo $Virology['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Virology['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-3">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Eye_Specialist['header'];?></h3>
<p class="font-italic">
<?php echo $Eye_Specialist['sub_header'];?></p>
<p><?php echo $Eye_Specialist['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Eye_Specialist['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-4">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Pediatrics['header'];?></h3>
<p class="font-italic">
<?php echo $Pediatrics['sub_header'];?></p>
<p><?php echo $Pediatrics['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Pediatrics['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-5">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Hepatology['header'];?></h3>
<p class="font-italic">
Qui laudantium consequatur laborum sit qui ad sapiente dila parde sonata raqer a videna mareta paulona marka</p>
<p>Et nobis maiores eius. Voluptatibus ut enim blanditiis atque harum sint. Laborum eos ipsum ipsa odit magni. Incidunt hic ut molestiae aut qui. Est repellat minima eveniet eius et quis magni nihil. Consequatur dolorem quaerat quos qui similique accusamus nostrum rem vero
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="assets/image/departments-5.jpg" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-6">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Neurology['header'];?></h3>
<p class="font-italic">
Qui laudantium consequatur laborum sit qui ad sapiente dila parde sonata raqer a videna mareta paulona marka</p>
<p>Et nobis maiores eius. Voluptatibus ut enim blanditiis atque harum sint. Laborum eos ipsum ipsa odit magni. Incidunt hic ut molestiae aut qui. Est repellat minima eveniet eius et quis magni nihil. Consequatur dolorem quaerat quos qui similique accusamus nostrum rem vero
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="assets/image/departments-5.jpg" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
</div><!--tab-content-->
</div><!--col-lg-9-->
</div><!--row-->
now the problem is the text fields shows fine but the problems is with image field
only the first image shows from cardiology group ..remaining images dont show and when i test virology (for example)with
var_dump it shows this
array (size=4)
'image' => int 604
'header' => string 'Virology' (length=8)
'sub_header' => string 'Virology Qui laudantium consequatur laborum sit qui ad sapiente dila parde sonata raqer a videna mareta paulona marka' (length=117)
'body_text' => string 'Virology Et nobis maiores eius. Voluptatibus ut enim blanditiis atque harum sint. Laborum eos ipsum ipsa odit magni. Incidunt hic ut molestiae aut qui. Est repellat minima eveniet eius et quis magni nihil. Consequatur dolorem quaerat quos qui similique accusamus nostrum rem vero' (length=279)
any help will be appreciated,thanks
When fields like image fields return integers rather than what they are supposed to return 99.9% of the time this is caused by a pre_get_posts filter that is interfering with ACF.
You need to look in your code for any pre_get_posts filters and alter them to not filter posts when they’re not supposed to be.
i have posts filter after that tab code not before that
but i added wp_reset_postdata();
but stilllthings dont work
see the full page code
<?php get_header();?>
<main id="main">
<!--Breadcrumbs Section-->
<section class="breadcrumbs">
<div class="container">
<div class="d-flex justify-content-between align-items-center">
<h2><?php the_title();?></h2>
</div>
</div><!--container-->
</section> <!--Breadcrumbs Section-->
<!--departments-inner-page-->
<section id="departments" class="departments">
<div class="container">
<div class="section-title">
<h2>Departments</h2>
<p>Magnam dolores commodi suscipit. Necessitatibus eius consequatur ex aliquid fuga eum quidem. Sit sint consectetur velit. Quisquam quos quisquam cupiditate. Et nemo qui impedit suscipit alias ea. Quia fugiat sit in iste officiis commodi quidem hic quas.</p>
</div>
<div class="row">
<div class="col-lg-3">
<ul class="nav nav-tabs flex-column">
<li class="nav-item">
<a class="nav-link active show" data-toggle="tab" href="#tab-1">Cardiology</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-2">Virologist</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-3">Eye specialist</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-4">Pediatrics</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-5">Hepatology</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tab-6">Neurology</a>
</li>
</ul>
</div><!--col-lg-3-->
<?php
$Department_tab = get_field('department_tab');
$Cardiology = $Department_tab['cardiology'];
$Virology = $Department_tab['virologist'];
$Eye_Specialist = $Department_tab['eye_specialist'];
$Pediatrics = $Department_tab['pediatrics'];
$Hepatology = $Department_tab['hepatology'];
$Neurology = $Department_tab['neurology'];
?>
<div class="col-lg-9 mt-4 mt-lg-0">
<div class="tab-content">
<div class="tab-pane active show" id="tab-1">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-l">
<h3> <?php echo $Cardiology['header'];?></h3>
<p class="font-italic">
<?php var_dump($Cardiology); ?>
<?php echo $Cardiology['sub_header'];?></p>
<p><?php echo $Cardiology['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Cardiology['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-2">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Virology['header'];?></h3>
<p class="font-italic">
<?php var_dump($Virology); ?>
<?php echo $Virology['sub_header'];?></p>
<p><?php echo $Virology['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Virology['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-3">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Eye_Specialist['header'];?></h3>
<p class="font-italic">
<?php echo $Eye_Specialist['sub_header'];?></p>
<p><?php echo $Eye_Specialist['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Eye_Specialist['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-4">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Pediatrics['header'];?></h3>
<p class="font-italic">
<?php echo $Pediatrics['sub_header'];?></p>
<p><?php echo $Pediatrics['body_text'];?>
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="<?php echo $Pediatrics['image'];?>" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-5">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Hepatology['header'];?></h3>
<p class="font-italic">
Qui laudantium consequatur laborum sit qui ad sapiente dila parde sonata raqer a videna mareta paulona marka</p>
<p>Et nobis maiores eius. Voluptatibus ut enim blanditiis atque harum sint. Laborum eos ipsum ipsa odit magni. Incidunt hic ut molestiae aut qui. Est repellat minima eveniet eius et quis magni nihil. Consequatur dolorem quaerat quos qui similique accusamus nostrum rem vero
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="assets/image/departments-5.jpg" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
<div class="tab-pane fade" id="tab-6">
<div class="row">
<div class="col-lg-8 details order-2 order-lg-1">
<h3><?php echo $Neurology['header'];?></h3>
<p class="font-italic">
Qui laudantium consequatur laborum sit qui ad sapiente dila parde sonata raqer a videna mareta paulona marka</p>
<p>Et nobis maiores eius. Voluptatibus ut enim blanditiis atque harum sint. Laborum eos ipsum ipsa odit magni. Incidunt hic ut molestiae aut qui. Est repellat minima eveniet eius et quis magni nihil. Consequatur dolorem quaerat quos qui similique accusamus nostrum rem vero
</p>
</div><!--col-lg-8-->
<div class="col-lg-4">
<img src="assets/image/departments-5.jpg" alt="department" class="img-fluid">
</div><!--col-lg-4-->
</div><!--row-->
</div><!--tab-pane-->
</div><!--tab-content-->
</div><!--col-lg-9-->
</div><!--row-->
</div><!--container-->
</section>
<!--doctors-inner-page-->
<section id="doctors" class="doctors">
<div class="container">
<div class="section-title">
<h2>Doctors</h2>
<p>Magnam dolores commodi suscipit. Necessitatibus eius consequatur ex aliquid fuga eum quidem. Sit sint consectetur velit. Quisquam quos quisquam cupiditate. Et nemo qui impedit suscipit alias ea. Quia fugiat sit in iste officiis commodi quidem hic quas.</p>
</div><!--section-title-->
<div class="row">
<?php
$args = array(
'post_type' => 'doctor',
'posts_per_page' => 4
);
$doctors = new WP_Query($args);
while($doctors->have_posts()){
$doctors->the_post();
?>
<div class="col-lg-6 mt-4 mt-lg-0">
<div class="member d-flex align-items-start">
<div class="pic">
<img src="<?php the_post_thumbnail_url('post_image'); ?>" class="img-fluid" alt="doctor">
</div><!--pic-->
<div class="member-info">
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<span><?php the_field('doctor_subheading'); ?></span>
<p><?php echo wp_trim_words(get_the_excerpt(),10);?></p>
<div class="social">
<a href=""><i class="ri-twitter-fill"></i></a>
<a href=""><i class="ri-facebook-fill"></i></a>
<a href=""><i class="ri-instagram-fill"></i></a>
<a href=""><i class="ri-linkedin-box-fill"></i></a>
</div><!--social-->
</div><!--member-info-->
</div><!--member-->
</div><!--col-lg-6-->
<?php } wp_reset_postdata(); ?>
</div><!--row-->
</div><!--container-->
</section><!--doctors-->
</main>
<?php get_footer();?>
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.