Hi @webmasterID
Can you check the source code on your page? Is the MARKUP for the nextgen gallery correct?
Can you also check your console log for any JS errors?
Perhaps also test the nextgen gallery in a WYSIWYG field which is at the root level (not in a flexible content field) for a comparison test.
Thanks
E
Thanks for the info.
In the end it was some closing tabs problem.
This is the final working code:
<?php
$images = get_field('gallery');?>
<ul class="gallery-link">
<?php foreach( $images as $image ): ?>
<li>
<a href="<?php echo $image['url']; ?>">
<img src="<?php echo $image['url']; ?>">
</a>
</li>
<?php endforeach; ?>
</ul>
The haystack gets a little smaller ;P
Either inside a loop or outside I run that snippet and get “bool(false)” as result with the admin bar and rest of page below where I put the snippet not displaying. If I remove the die; I get rest of page but same result.
All results from postid = 64 from postmeta table are screenshot to http://imgur.com/vKiw951 – It does not have a reference value in the table though the rest of the meta fields useful data is present.
Hi @pouki
Your issue is not with the image field, it is with loading data form a user. Please read the docs here:
http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-user/
Thanks
E
Have you confirmed that in the source code, the gallery field markup is not being created?
My first thought is that the $images variable is not working because you are using ‘Gallery’ as the field name. Shouldn’t this be ‘gallery’?
Thanks
E
Hi @Phil Futureproof
Sorry, but this forum is a free support service for issues and bugs, not to receive free theme development.
As a tip, the function get_sub_field
will NOT WORK in the context that you have coded. That function only works within a has_sub_field loop, not a foreach loop.
Please read the docs
Thanks
E
Hi Elliot – Thanks for the Debugging info – very useful and I now have a page that is at least rendering in a browser window.
Still working on this if statement issue – at the moment on the page, all thumbnails open up to the full size image. However, I’m trying to have a situation where, if I’ve entered a url in repeater/subfield 2 then I want it to go to that url rather than load the image. For me, the fact that this doesn’t work implies that the if($links) part of the code (see below) is always taking the else option, so I need to solve what’s wrong with the first part/option, or if it’s not that, the overall structure of the if statement may be at fault. As I said before, this is beyond my current coding knowledge and would appreciate if you could have a look & see if you can see what’s wrong.
For instance – do I have to include a foreach($links as $link) in this section, similar to the foreach($rows as $row) in the previous bit of code? This might not be the case, but this is where my coding knowledge falls short and any help would be most appreciated.
To view the page I’m working on in a browser please click here
Many thanks in advance for your help
Phil
<?php
// using normal array
$rows = get_field('press_badge');
if($rows)
{
echo '<ul id="pressBadgesList" class="pressBadgesList">';
foreach($rows as $row)
{
echo '<li>' . '<div class=\'radio_badge_title\'><p>' . $row['press_title_printed'] . '</p></div>';
$links = get_sub_field('press_url');
if($links) {
echo '<' . 'a ' . 'target=' . '\'_blank\'' . 'href=' . $row['press_url'] . '>' ;
}
else
{echo '<' . 'a ' . 'rel=\'lightbox[reviews]\'' . 'href=' . $row['press_image_printed'] . '>'; }
echo '<' . 'img src=' . $row['press_image_printed'] . ' width=\'150\'' . 'height=\'150\'' . '>' .'</a>'.'</li>';
}
echo '</ul>';
}
?>
I have been trying to solve this same issue today so thought I would post my code in case other were having a similar issue
<?php
$slug = get_page_by_path( 'blog' );
if (is_single()) { ?>
<h1><?php echo the_excerpt(); ?></h1>
<?php } elseif (is_home()) { ?>
<h1><?php the_field('page_heading', $slug->ID); ?></h1>
<?php } else { ?>
<h1><?php the_field('page_heading'); ?></h1>
<?php } ?>
Hi @Phil Futureproof
You say “blank page”. Do you mean a completely white page? If so, you have a PHP error on the page which is preventing the HTML from being rendered.
To diagnose this, you will need to turn on DEBUG MODE in your wp-config file and fix the errors reported.
If this is not the issue, you need to remove all your code and add it in 1 line at a time until you find the line which is not working. This may be the first line of code, but it is smart to debug your code 1 bit at a time as it is easier to solve this way.
for instance:
$rows = get_field(‘press_badge’);`
vae_dump( $rows );
`
Sorry Arcanepsyche, I tried to be as clear as possible.
You ask what is not working. Well . . . to answer that, the page just comes up with no content at all – just a blank page! so I guess I’ve made a mistake in the coding somewhere & I believe the problem is in the area marked // Start/End of section that doesn’t work – since if I remove that bit of code the page renders but without the link.
On the other point – interesting that you say I should be using get_sub_field instead of get_field – however, I have just replaced get_field with get_sub_field in the section of code not working (like you suggested) but it still just creates a blank page (see below for code) – As i said before my php coding is basic to say the least and would appreciate any help you can give. Many thanks Phil
<div class="radioBadges">
<?php
// using normal array
$rows = get_field('press_badge');
if($rows)
{
echo '<ul id="pressBadgesList" class="pressBadgesList">';
foreach($rows as $row)
{
echo '<li>' . '<div class=\'radio_badge_title\'><p>' . $row['press_title_printed'] . '</p></div>' ;
// Start of section that doesn't work
$links = get_sub_field('press_url');
if($links) {
echo '<' . 'a ' . 'target=' . '\'_blank\'' . 'href=' . $row['press_url'] . '>'
}
else
{echo '<' . 'a ' . 'rel=\'lightbox[reviews]\'' . 'href=' . $row['press_image_printed'] . '>' };
// End of section that doesn't work
echo ('<' . 'img src=' . $row['press_image_printed'] . ' width=\'150\'' . 'height=\'150\'' . '>' .'</a>'.'</li>');
}
echo '</ul>';
}
?>
</div>
First of all, you didn’t say exactly what is not not working which makes it hard to diagnose.
Secondly, if you’re using a repeater, shouldn’t you be using get_sub_field instead of get_field?
Just a couple shots in the dark before Elliot responds.
Hi @dashaluna
I’m not 100% I understand your reply, but ye, you can select a different option on the taxonomy field for it to render as a single select field type such as radio or select
Thanks
E
Display is controlled for the custom post type “course”:
<?php
/**
* The Template for displaying all single courses. Nimmo version
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
wp_enqueue_style(‘courses’, get_stylesheet_directory_uri() . ‘/lib/courses/courses.css’);
function nim_courses_content($content){
// render the ACF plugin fields.
if ( function_exists( ‘the_field’ ) ) {
// Print the CCSS/CCR logo if selected
$standard = (get_field(‘standard’));
if (!empty($standard)) {
echo ‘<div class=”standards-wrap”>’;
if( in_array( ‘College & Career Ready’, $standard ) ) echo ‘<div class=”ccr-logo”></div>’;
if( in_array( ‘Common Core’, $standard ) ) echo ‘<div class=”ccss-logo”></div>’;
echo ‘</div>’;
}
if (get_field( ‘course_description’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘course_description’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘course_description’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘learning_outcomes’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘learning_outcomes’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
echo “
“;
endwhile; ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘target_audiences’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘target_audiences’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘target_audiences’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘format’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘format’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘format’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘grades’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘grades’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘grades’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘prerequisites_required’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘prerequisites_required’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value course-field-fullwidth”>
<?php
$courseIDs = get_field( ‘prerequisites_required’ );
foreach( $courseIDs as $courseID ) {
echo ‘‘ . get_the_title($courseID) . ‘<br />’;
} ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘related_courses’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘related_courses’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value course-field-fullwidth”>
<?php
$courseIDs = get_field( ‘related_courses’ );
foreach( $courseIDs as $courseID ) {
echo ‘‘ . get_the_title($courseID) . ‘<br />’;
} ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘next_steps’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘next_steps’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value course-field-fullwidth”>
<?php
$courseIDs = get_field( ‘next_steps’ );
foreach( $courseIDs as $courseID ) {
echo ‘‘ . get_the_title($courseID) . ‘<br />’;
} ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘downloadables’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘downloadables’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value course-field-fullwidth”>
<?php
while( has_sub_field( ‘downloadables’ )):
$fileID = get_sub_field( ‘file’ );
$title = get_sub_field( ‘title’ );
echo ‘‘ . $title . ‘<br />’;
endwhile; ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘purchasables’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘purchasables’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value course-field-fullwidth”>
<?php
while( has_sub_field( ‘purchasables’ )):
$url = esc_url( get_sub_field( ‘url’ ) );
$title = get_sub_field( ‘link_title’ );
echo ‘‘ . $title . ‘<br />’;
endwhile; ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘specials’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘specials’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘specials’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘item_number’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘item_number’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘item_number’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘price’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘price’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php echo “\$” . get_field( ‘price’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
if (get_field( ‘participants’ )) { ?>
<div class=”course-field-wrap”>
<div class=”course-field-title”>
<?php $field_object = get_field_object( ‘participants’ ); ?>
<h3><?php echo $field_object[‘label’]; ?></h3>
</div> <!– .course-field-title –>
<div class=”course-field-value”>
<?php the_field( ‘participants’ ); ?>
</div> <!– .course-field-value –>
</div> <!– .course-field-wrap –> <?php
}
}
echo ‘<br />’;
//echo $content;
}
add_filter(‘the_content’, ‘nim_courses_content’);
get_header(); ?>
<div id=”primary”>
<?php get_sidebar(‘what-we-offer’); ?>
<div id=”content” role=”main”>
<?php while ( have_posts() ) : the_post(); ?>
<nav id=”nav-single”>
<h3 class=”assistive-text”><?php _e( ‘Post navigation’, ‘twentyeleven’ ); ?></h3>
<span class=”nav-previous”><?php previous_post_link( ‘%link’, __( ‘<span class=”meta-nav”>←</span> Previous’, ‘twentyeleven’ ) ); ?></span>
<span class=”nav-next”><?php next_post_link( ‘%link’, __( ‘Next <span class=”meta-nav”>→</span>’, ‘twentyeleven’ ) ); ?></span>
</nav><!– #nav-single –>
<?php get_template_part( ‘content-single’, get_post_format() ); ?>
<?php endwhile; // end of the loop. ?>
</div><!– #content –>
<?php get_sidebar(‘courses’); ?>
</div><!– #primary –>
<?php get_footer(); ?>
Hi @dashaluna
Yes, there are location rules for taxonomy.
This will allow you to create a Video and select a taxonomy (not sure what your taxonomy name is), and ACF will fetch any field groups with matching location rules given the taxonomy selection.
Thanks
E
Hi @andiszek
Have you done much code debugging yet? Have you tested what value is returned by get_field('opt_sidebar_topdestin','option')
?
Can you confirm that any code is running in this widget correctly?
Thanks
E
This should work:
– Create a Field Group
– Add a Repeater
– Add Sub Fields to Repeater
– Add two Radio Button Fields to Field Group (Not as sub fields in the repeater!)
I have these fields in my Field Group:
“Repeater” => Repeater Field
“IMG” => Repeater Sub Field, Field Type = Image, Return Value must be “Image ID”
“IMG Title” => Repeater Sub Field, Field Type = Text
“Row Sort” => Field Type = Radio Button, Default Value = “default”, Choices are set to:
default : default
random : random
reverse : reverse
“Row Limit” => Field Type = Radio Button, Option “Add ‘other’ choice to allow for custom values” is checked. Default Value = “3”, Choices are set to:
1 : 1
2 : 2
3 : 3
When the user creates a post, they can limit the number of Repeater rows to show and choose how the rows should be sorted (e.g. Random Order + Displaying 5 Rows).
Tested and works, could probably clean code up or do some of it differently… this is what my tired mind came up with 🙂
<?php
$row_sort = get_field('row_sort' ); // radio button: random/reverse/default
$row_limit = get_field('row_limit'); // radio button: 1/2/3/Custom
$rows = get_field('repeater' );
$sub_field = has_sub_field('repeater');
$img = get_sub_field('img');
$img_title = get_sub_field('img_title');
if($rows) {
echo '<h3>My List</h3>';
echo '<ul>';
for($i=0; $i < $row_limit; $i++) // Limits Rows based on field "Row Limit"
{
if($row_sort == "random") { // Random Order
/* Display Images Randomly (e.g. If 10 images have been added and Row Limit is set to 5, 5 Random Images will Display), $image[0] will pull the image links */
$rand_row = $rows[ array_rand( $rows ) ];
$rand_row_image = $rand_row['img' ];
$image = wp_get_attachment_image_src( $rand_row_image, 'full' );
echo '<li>';
echo $image[0]; // Return Value for Image must be set to "Image ID"
echo '</li>';
} elseif($row_sort == "reverse") { // Reversed Order
/* Displays links to images in reversed order. If 10 images and Row Limit is set to 5, Images 10, 9, 8, 7, 6 will display */
$rowArray = get_field('repeater' );
$reversedArray = array_reverse( $rowArray );
if($reversedArray) {
$reversedArray = has_sub_field('repeater');
$img = get_sub_field('repeater');
$img_title = get_sub_field('repeater');
echo '<li><a href="' . $img . '">' . $img_title . '</a></li>';
}
} else { // Default Order
/* Displays list of Image Titles like it normally would, but limited to Row Limit */
$default = get_field('repeater' );
$default = has_sub_field('repeater');
if($default) {
$img_title = get_sub_field('repeater');
echo '<li>' . $img_title . '</li>';
}
}
}
echo '</ul>';
} ?>
Hi @lkamms
Sounds like you have upgraded from ACF v3.x to v4.x
This transition introduced a new way to create field types. v3 field types are no longer compatible with v4 (this is heavily documented).
I believe that your website contains a ‘buy now’ field type which was built from v3, but not for v4.
My advice would be to contact the dev team from the build and ask them if this is the case. If so, I would hire them to rebuild the field into a v4 compatible version. This is a pretty simple task as there is a starter kit available on github and documentation on the resources page.
Hope that helps.
Thanks
E
I’ve somehow gotten rid of the endwhile syntax error by cleaning up the comments elsewhere in the template.
But I’m still left with no data displaying. I’ve fleshed out the snippet with the rest of the fields from that repeater field. This is the full code bit that I currently have, but still nothing displays.
<div class="patrol-bulletin-data">
<?php if( get_field('summary_section') ): ?>
<php while ( has_sub_field('summary_section') ): ?>
<div class='summary-data'>
<?php the_sub_field('bulletin_summary'); ?>
<?php the_sub_field('location'); ?>
<?php the_sub_field('report_number'); ?>
<?php the_sub_field('incident_date'); ?>
<?php the_sub_field('incident_time'); ?>
</div>
<php endwhile; ?>
<?php endif; ?>
</div>
Hi @mharding
Your value shows clearly that you are trying to render an array. This is not possible in PHP. You need to only echo the $value[‘url’] or the size you want.
Please read up on the image field docuemtnation to fully understand how the image object vs the image ID return value works.
Thanks
E
Ok cool, I’m glad I’m making sense!
I’m using an acf select field, configured like this:
Field Name: q_and_a_category_select
Field Type: Select
Choices
design : Design
engineering : Engineering
project-management : Project Management
To fill you in on the history, originally I had three separate page templates, each displaying posts from a specific term. For example, I used this for the Design page:
<?php $args=array(
'post_type' => 'q-and-a',
'q_and_a_category' => 'design' //the slug for the custom taxonomy term
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<?php the_title(); ?>
<?php endwhile; }?>
<?php wp_reset_query(); ?>
This works great to show just the q-and-a custom posts assigned the term “design”, but I didn’t want to have separate templates for each one.
So the first thing I tried was this:
‘q_and_a_category’ => ‘<?php the_field(“q_and_a_category_select”); ?>’
I figured it would simply just plug in the proper term and I’d be good to go. But it didn’t work and I’m not skilled enough in php to know why not.
So I did some searching and found this acf tutorial: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values
Seems like example 3 should do it, but no luck.
Thanks again!
Hi!
Well, it shouldn’t be listed as a “list” as in
or
.. I want it listed in one line without touching the css so I coded it that way.. Also, there is a possibility that not all the Doctors will have a “Sub Specialty” that’s why there’s this line of code:
<?php
if (get_field('sub_specialty') != '') { ?>
I removed the array($terms);
too. =]
Here’s my final code on displaying the term name:
<?php
$terms = get_field('sub_specialty');
foreach ($terms as $term){
$subspec[] = '<a href="'.$term->slug.'" name="'.$term->slug.'" alt="'.$term->anem.'">'. $term->name .'</a>';
}
echo implode(' / ', $subspec);
?>
Hey guys.
ACF v4.2.2 fixes the issue.
Thanks again for your quick bug reporting!
Cheers
E
Aw shucks, Joel. I’m blushing. 🙂
I haven’t had a chance to test it yet (noisy clients). But Ciceron seems like a pretty smart guy. I’d go with his assessment. 🙂
I downloaded and installed the latest “acf-master” from Github. Works fine for me now. Admin fields work properly, and the public display pages are showing the relationships, too.
Thanks Elliot!
(P.S. I’ve only installed this on a development copy of the site, not on the live site yet. I’ll wait for the official dot-release.)
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.