if ( !current_user_can('manage_options')) {
// modify the order
$current_user = wp_get_current_user();
$user_id = $current_user->ID;
$args['author']=$user_id;
$args['authors']=$user_id;
$args['post_type']='stand';
return $args;
}
else { $args['post_type']='stand'; return $args; }
is_admin
Description
This Conditional Tag checks if the Dashboard or the administration panel is attempting to be displayed. It should not be used as a means to verify whether the current user has permission to view the Dashboard or the administration panel (try current_user_can() instead). This is a boolean function that will return true if the URL being accessed is in the admin section, or false for a front-end page.
Usage
<?php is_admin(); ?>
and what is your posts custom field name?
add_filter(‘acf/fields/post_object/query/name=stand
‘) <= not post type name, but ACF custom field name
did you also changed
// filter for every field
add_filter(‘acf/fields/post_object/query/name=franchise’, ‘my_post_object_query’, 10, 3);
name=franchise
with your field slug?
so if it’s not working you may try the second way with json handling as php scripts in acf-json folder
During ACF’s initialization procedure, all .json files within the acf-json folder will be loaded. By default ACF looks for a folder within your theme called acf-json, however, this is only 1 of the load points which can be added.
you have to set path[0] i guess
your $paths[] = get_stylesheet_directory() . '/acf-json/truck';
;
just puts another array array element to $paths but ACF as i know uses just $paths[0]
add unset($paths[0])
at first line of your function
First try to deactivate your plugins except ACF and see whats happened
I guess some of your plugins changes behavior of how wp shows custom post types
or the second way
add .htaccess to your local json folder with AddHandler php-script .json
then create your local.json with php code that dynamicly generate it’s contents based on your options
add_filter('acf/settings/load_json', 'my_acf_json_load_point');
function my_acf_json_load_point( $paths ) {
$custom-json-folder = '';//PUT HERE YOUR PATH LOADER BASED ON OPTIONS
unset($paths[0]);
$paths[] = get_stylesheet_directory() . '/my-custom-folder/'.$custom-json-folder;
// return
return $paths;
}
add this to your .htaccess file and see what error will be shown on ‘blank page’
php_flag display_errors on
yeah i found =)
post object field uses get_posts for all post types and get_pages for pages
so if you want to filter them both
use
$args['author']=$user_id;
$args['authors']=$user_id;
but if you using custom post type why you didnt set the post type filter in the custom field options?
forgot some quotes =)
maybe’ll help
function my_func_filter($args, $field, $post){
$args['post_parent'] = $post->ID;
return $args;
}
add_filter('acf/fields/relationship/query/name=YourACFFieldSlug', 'my_func_filter', 10,3);
use options page addon
use author instead of post_author
// ADD NEW COLUMN
function v2008_c_head($defaults) {
$column_name = 'solution';//column slug
$column_heading = 'Solution';//column heading
$defaults[$column_name] = $column_heading;
return $defaults;
}
// SHOW THE COLUMN CONTENT
function v2008_c_content($name, $post_ID) {
$column_name = 'solution';//column slug
$column_field = 'solution_type';//field slug
if ($name == $column_name) {
$post_meta = get_post_meta($post_ID,$column_field,true);
if ($post_meta) {
echo $post_meta;
}
}
}
// ADD STYLING FOR COLUMN
function v2008_c_style(){
$column_name = 'solution';//column slug
echo "<style>.column-$column_name{width:10%;}</style>";
}
add_filter('manage_solutions_posts_columns', 'v2008_c_head');
add_action('manage_solutions_posts_custom_column', 'v2008_c_content', 10, 2);
add_filter('admin_head', 'v2008_c_style');
yet without filtering
added localization support
added ACF Field Groups language option
added xili-language support
function addacf_image($field){
if ($field['_name']=='YourFieldName') {
echo '<p>Your image should be here</p>';
}
return $field;
}
add_filter('acf/create_field','addacf_image',10,1);
to your functions.php
Hmm, I just tested it on my site and all works fine
Made plugin for Polylang (language plugin) with language field option.
https://github.com/VoiD2008/acf_wpml_fields
WPML and xili-language support pending
function my_acf_load_field( $field ){
global $post;
$post_language_information = wpml_get_language_information($post->ID);
if (strpos($field['name'],'_wpml')>0)
if (!strpos($field['name'],'_'.$post_language_information['locale']))
return;
return $field;
}
add_filter('acf/load_field', 'my_acf_load_field');
for example you have fields text_wpml_ru and text_wpml_en
if your post locale is en you’ll see only text_wpml_en
and all fields if their names doesnt contain ‘_wpml’
I had the same issue and solved it this way:
when I save my post wp generates a serialized array and saves it to post_meta
function update_vol( $post_id ) {
if (get_post_type($post_id)=='volumes'){ //check for my custom post type with tons of data
$post = get_post($post_id);
setup_postdata($post);
$fields = get_fields();
$field_values = array();
if( $fields )
foreach( $fields as $field_name => $value ){
if (!is_object($value)) // checking for value is not an post object
$field_values[$field_name]=$value; // storing data to array
}
$field_values_fordb = serialize($field_values); //serializing our array
$add_check = add_post_meta($post_id,'serialized_',$field_values_fordb,true); //trying to store our values to db using ADD method
if (!$add_check) update_post_meta($post_id,'serialized_',$field_values_fordb); //if ADD method failed trying UPDATE method
}
wp_reset_postdata()
}
add_action( 'save_post', 'update_vol' );
so at front-end I work only with one meta field ‘serialized_’
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.