Hm, one problem is that, the rows appear all in one line, i.e., there’re no line breaks. Could you help me with it please?
Thanks!
I solved it by using some CSS.
<?php
$images = get_field('gallery');
$image_1 = $images[0];
?>
<?php foreach( $images as $image ): ?>
<a href="<?php echo $image['url']; ?>" rel="fancybox"><img src="<?php echo $image_1['url']; ?>" /></a>
<?php endforeach; ?>
<div id="slideshow_thumb_info">
<?php echo $image_1['title']; ?><br>
<?php echo $image_1['caption']; ?>
</div>
#slideshow_thumb img {
display:none;
width:100%;
height:auto;
}
#slideshow_thumb a:first-of-type img{
display:block;
}
#slideshow_thumb_info {
color:black;
padding-top: 10px;
font-size: 10px;
line-height: 12px;
}
I solved it by adding [url] after $image_1 in the img tag.
There was a field that I deleted. I think that must’ve been causing the problem. I deleted the whole field group and created a new one, and that solved the problem.
Thanks!
This is the php file for the page;
<?php
/*
Template Name: Abous Us - Parent
*/
?>
<p>test</p>
<?php get_header(); ?>
<div id="content" class="group">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
$content = apply_filters( 'the_content', $content );
?>
<div id="aboutSub"><div class="entryHeader"><?php echo $page->post_title; ?></div>
<div class="entry"><?php echo $content; ?><img src="<?php the_field('image1'); ?>" alt="" /></div></div>
<?php
}
?>
<?php endwhile; endif; ?>
</div><!-- END content -->
<?php get_footer(); ?>
Child pages use default page templates.
Hi Elliot,
I pasted it into the page, as you can see;
This page is the parent page of the pages “Our Products” and “Our People” from which I’m trying to pull the image fields from.
Thanks.
Hi Elliot,
1. THe return type is URL
1. I’m using the code in this archive-blog.php that I created a custom post type “blog.” I want to show up the images next to texts. Here;
3. 80 is the page is of the child page “Our People”
Thanks,
Jaeeun
Hi,
I tried this code
<?php the_field('image1', 80); ?>
But the image still doesn’t show up.
Also, is there a way to target all the child pages in general, instead of targeting a specific child page by its ID?
Thanks,
Jaeeun
Oh I deleted line 5 and now it works! Hmmm.
Thanks a lot for your help.
Yes, Chrome says:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8888/lib/jquery.bxslider.css
Uncaught TypeError: Object #<Object> has no method ‘on’ jquery.bxslidercustom.js?ver=3.5.2:5
I put the css code in my style.css instead of calling jquery.bxslider.css
jquery.bxslidercustom.js is the java file for that I created to produce the pop up slider effect. Line 5 of it is;
$rs(window).on('resize', doResize);
SO, I changed my code to this;
<div id="slide-window">
<?php if(get_field('gallery')): ?>
<div class="slidemargin">
<a href="#" id="close"><img src="http://localhost:8888/underdonk/wp-content/themes/underdonk/images/close.jpg" /></a>
<ul id="slider">
<?php while(has_sub_field('gallery')): ?>
<li><div class="slide-image"><img src="<?php the_sub_field('image'); ?>"alt=""/></div>, <div class="slide-info"><?php the_sub_field('title'); ?></div></li>
<?php endwhile;?>
</ul>
<a id="prev" href="#"><img src="http://localhost:8888/underdonk/wp-content/themes/underdonk/images/prev.jpg" /></a>
<a id="next" href="#"><img src="http://localhost:8888/underdonk/wp-content/themes/underdonk/images/next.jpg" /></a>
</div><!--.slidemargin -->
<?php endif; ?>
</div><!--#slide-window -->
And now the images pop up, but they are overlapped on each other, and when I click the next or prev button nothing happens. This is my java code in case;
$bx('#prev').click(function(){
slider.goToPreviousSlide();
return false;
});
$bx('#next').click(function(){
slider.goToNextSlide();
return false;
});
But the name of the sub field is ‘image’
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.