
Hi @develop,
If images are showing up blank it sounds like there might be an error in the path to the uploaded file. You can check this by going to the Media section in the WordPress admin, clicking on the image and checking it’s URL field.
For hiding images in the media folder you’ll probably need to do something like: http://wordpress.stackexchange.com/a/105465/12291

Had this exact issue, wrote a blog post about it here: https://www.ractoon.com/2016/08/wordpress-acf-pro-files-field-custom-upload-directory/
But your code would end up looking something like:
add_filter( 'acf/upload_prefilter/name=secure_files', 'secure_upload_prefilter' );
add_filter( 'acf/prepare_field/name=secure_files', 'secure_files_field_display' );
public function secure_upload_prefilter( $errors ) {
add_filter( 'upload_dir', 'secure_upload_directory' );
return $errors;
}
function secure_upload_directory( $param ) {
$folder = '/s2member-files';
$param['path'] = WP_PLUGIN_DIR . $folder;
$param['url'] = WP_PLUGIN_URL . $folder;
$param['subdir'] = $folder;
$param['basedir'] = WP_PLUGIN_DIR;
$param['baseurl'] = WP_PLUGIN_URL;
return $param;
}
public function secure_files_field_display( $field ) {
// update paths accordingly before displaying link to file
add_filter( 'upload_dir', 'secure_upload_directory' );
return $field;
}
Where the secure_files portion of the add_filter would be your field name instead.
Then in the secure_upload_directory() function you could use https://codex.wordpress.org/Function_Reference/get_home_path to grab the absolute path to the install location.

Is the user you’ve saved data for user 1?
This code:
get_field( 'test_field', 'user_1' );
Gets the data for user ID 1. If you wanted user ID 9 you’d need to do:
get_field( 'test_field', 'user_9' );
For example.
If you’re not seeing the data even in the wp_usermeta table something else may be going on as well.

If you’re trying to get a field for the current page you shouldn’t need to set the ID parameter.
You can just say:
get_field('title');
But if you wanted to pass the ID for some reason you could do:
get_field('title', get_the_ID());
If you’re on another page you will need to pass the ID for the page/post you’re trying to get the data from.

wp_current_user() returns a User object. To get the ID you would need to access it like:
$current_user->ID
So your code would be updated to:
$current_user = wp_get_current_user();
$new_post = array(
'post_title' => 'Planner for '.$current_user->display_name,
'post_type' => 'planner',
'user_id' => $current_user->ID,
'post_author' => $_SESSION['USER_ID'],
'post_status' => 'publish'
);
$post_id = wp_insert_post( $new_post, $wp_error );
if (is_wp_error($post_id)) {
$errors = $post_id->get_error_messages();
foreach ($errors as $error) {
echo $error;
}
}

Recently updated my solution at https://www.ractoon.com/2014/11/acf5-pro-color-picker-custom-palettes/ to address performance issues and compatibility with recent ACF PRO versions. Can give it a shot and see if it works for you as well.

Is there a default value on the field of “http://”? It looks like it is partially filled which will trigger an error, removing the default value and leaving it blank should allow it to save.

You might look into https://wordpress.org/plugins/shortcodes-ultimate/ – has hooks to add your custom shortcodes and modify the default ones. Has a nice interface for both.

When adding/editing a field group it should be within the “Location” section with the rule “Show this field group if” Post Type is equal to Your Custom Post Type

Might look at a plugin such as https://wordpress.org/plugins/relevanssi/ which can generate an index that includes all custom fields, do fuzzy matching, etc. In the configuration you can set it to look at all custom fields which should do what you’re looking for.
By default the plugin will upgrade the built-in search, but you can also use it in custom searches/queries if you need to as well.

Looks like just a minor typo possibly. In your first <td> you’ll need to echo your values. Also, the permalink variable was not declared. Might try:
if( $posts ):
foreach( $posts as $post ):
$fww_title = get_the_title( $post->ID );
?>
<tr>
<td><a href="<?php echo get_permalink( $post->ID ); ?>"><?php echo $fww_title; ?></a></td>
<td>test</td>
<td><?php the_field('player_gender', $post->ID); ?></td>
<td><?php the_field('player_level', $post->ID); ?></td>
<td><?php the_field('player_city', $post->ID); ?>, <?php the_field('player_state', $post->ID); ?></td>
<td><?php the_field('player_phone', $post->ID); ?></td>
<td><?php the_field('player_email', $post->ID); ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>

You’ll probably want to use get_field instead of the_field in your assignment. the_field will display the retrieved value automatically which is why you’re seeing duplicate output.
<?php
$adkCopyright = get_field( 'adk_copyright', 'option' );
if ( !empty( $adkCopyright ) ) {
echo $adkCopyright;
} else {
echo bloginfo( 'name' );
}
?>

Ran into this as well and made a blog post about how to do it: http://www.ractoon.com/2014/11/acf5-pro-color-picker-custom-palettes/


In your repeater that is not working (the one storing post id for images) do the images exist in the media gallery with those IDs?

Hmm, could you paste the full code for this section?

Are you using the update_field() function to set the value when you populate the custom fields during import?
If so, are you using the field_key value such as:
$field_key = "field_5039a99716d1d";
$value = "some new string";
update_field( $field_key, $value );
Full docs: http://www.advancedcustomfields.com/resources/update_field/#finding-the%20field%20key

You’ll want to wrap a check around the field value, something like:
<?php
$term_id = get_queried_object_id($current_category);
if ( $val = get_field('field_name', 'category_' . $term_id) ) {
// do stuff here if field is not empty
}
?>

Maybe something like:
<?php if( have_rows('modules') ): ?>
<?php $menu_items = ''; ?>
<?php while ( have_rows('modules') ) : the_row();
if( get_row_layout() == 'photo' ):
$menu_items .= '<li><img src="' . get_sub_field('photo') . '" alt="' . get_sub_field('menu_name') . '"><li>';
elseif( get_row_layout() == 'text' ):
$menu_items .= '<li>' . get_sub_field('menu_name') . ' ' . get_sub_field('text') . '</li>';
<?php endif; endwhile; ?>
<ul>
<?php echo $menu_items; ?>
</ul>
<?php endif; // end modules has rows ?>

Yep, so there’s a couple pieces involved with displaying the map. Full code/instructions can be viewed at: http://www.advancedcustomfields.com/resources/google-map/#code-examples

Nice, glad to be of service 🙂

Does this work:
<div class="postinner-h1">
<h1><?php echo single_cat_title(); ?> günstig online kaufen!</h1>
<?php
$term = get_queried_object();
if ( $term ):
?>
<p><?php echo get_field( 'short_description', $term->taxonomy . '_' . $term->term_id ); ?>
<?php endif; ?>
</div></div>

Could you paste the code from your category page?

In your sample $lien contains the <br> in the string, whereas $lien2 only contains the link string and not the <br>.
If you do this it should return true:
$lien = get_field('fieldName');
echo $lien.'<br/>';
$lien2 = 'http://link.com';
echo $lien2.'<br/>';
if($lien2==$lien):
echo "same";
else:
echo "not same";
endif;

Those items are fields from a taxonomy. Say you’re wanting to list out the default category taxonomy, you’d need to do something like:
$terms = get_terms( 'category' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . '</li>';
}
echo '</ul>';
}
That will output the name of all the categories you’ve created. If you want to output your custom field as well you’ll add your get_field() like:
$terms = get_terms( 'category' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach ( $terms as $term ) {
echo '<li>' . $term->name . ' - ' . get_field('short_description', $term->taxonomy . '_' . $term->term_id) . '</li>';
}
echo '</ul>';
}
For the get_field() function you’re passing your field name short_description along with the $term->taxonomy and $term->term_id separated by an underscore.
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.