Forum Replies Created

  • From ACF posts.php and api-field-groups.php, this should get you started:

    $posts = get_posts(array(
      'post_type' => 'acf-field-group',
      'posts_per_page' => -1,
      'orderby' => 'menu_order title',
      'order' => 'asc',
      'suppress_filters' => false, // allow WPML to modify the query
      'post_status' => 'publish',
      'update_post_meta_cache' => false
  • Have you tried forcing it to use the default visual editor in your theme’s functions?

    add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );

    I run both latest VC and ACF and don’t see this issue.

  • The second parameter of the remove_meta_box method takes the post_type. So if your custom post type is “products”, just do remove_meta_box("wpseo_meta", "products", "normal");

    Also, keep in mind that the third parameter is one of “normal”, “advanced”, or “side” and is dependent on where that meta box is situated. Basically, if normal doesn’t work, try advanced. 🙂

  • use get_field(), not the_field(). the_field method is attempting to echo the value. Not what you want in this instance as you are assigning that value to a variable.

  • Why not use a custom post type (products) with a rewrite to store. That way your /store url will be the archive page for your products. The client can just add products as custom posts, complete with your mapped ACF fields, and they will automatically pull into that post type archive, i.e. /store.

  • This is an issue with Visual Composer. They are failing to do a sanity check to ensure that the array is not returning empty. You’ll notice the error path comes from …plugins/js_composer… not from ACF’s plugin. The reason deactivating it worked is because VC was no longer looking for anything from ACF.

    More to the point, perusing the code it appears you may have a field group defined in ACF that actually has no fields within it. Which would cause that error. However I can’t tell for sure without knowing your setup.

  • Add this to your functions.php:

    add_action('admin_head', 'remove_metaboxes_for_non_admin');
    function remove_metaboxes_for_non_admin(){
    	if (!is_admin()){ // only remove for non admins
    		remove_meta_box('wpseo_meta', 'post', 'normal'); // removes the wordpress seo by yoast metabox from posts
    		remove_meta_box('wpseo_meta', 'page', 'normal'); // removes the wordpress seo by yoast metabox from pages
    		// continue adding as necessary

    See here for remove_meta_box reference.
    You can find the “ids” of the metaboxes by inspecting the code to see what the id is for the div wrapping the box.

  • If not the color’s hex value, what are you trying to get?

  • For that I would want to run everything through local JSON. Then tie into the WP create_category hook. Each time a new category is created, parse the json from the local file and update it. ACF will then pull the data from that json file instead of from the DB.

  • I modified the post_object.php field to accomplish this. It’s attached.

    There is a method called acf_get_taxonomy_terms() that is getting all the terms for the options. I pulled that function from the api-helpers.php file and updated it slightly to include the ‘parent’ => 0 parameter in its get_terms() call. I put the new method in my updated file and called it instead of acf_get_taxonomy_terms() and it seems to work as expected. Adding it as a new field option is the easiest way. Look at Creating a New Field Type to see how to do that. For this though, you can just add the attached file to your system (I just included it at the bottom of my functions.php file) and it should become available.

  • You are attempting to get the index value of a string here. To explain:

    The following code results in an array:
    $rows = get_field(‘location’, ‘option’);

    Then you are using the 0 index to get the first value of that array, which will result in yet another array, only this time associative:
    $first_row = $rows[0]

    Finally, you are able to target the actual field you are looking for by it’s field label, in this case ‘location_phone’:
    $first_row_phone = $first_row[‘location_phone’ ];

    What results from that line of code is the string value you are looking for. By echoing out echo $first_row_phone[0]; you are confusing PHP into trying to get the index value of a string. So really, all you need to do is echo the string itself: echo $first_row_phone;

    Long story short, remove the ‘[0]’ from the echo.

  • You could just create a function that loops through all your posts and checks the time, and if expired updates the post status to draft. Run it on cron to keep it from killing performance.

    if (!wp_next_scheduled('expire_posts')){
      wp_schedule_event(time(), 'daily', 'expire_posts');
    add_action('expire_posts', 'expire_posts_function');
    function expire_posts_function() {
    	$today = time();
    	$args = array(
    		'post_type' => array('post'), // array of the post types you want to check
    		'posts_per_page' => -1 // get all the posts
    	$posts = get_posts($args);
    	foreach($posts as $p){
    		if(get_field('expiration', $p->ID) > $today){
    			$postdata = array(
    				'ID' => $p->ID,
    				'post_status' => 'draft'
  • The result of the relationship field is going to be an array of pages, even if only one is selected. So you would either need to loop through them or target the array index. Furthermore the result of each item in the array is an object.

    The loop would be:

    $companies = get_field('company');
    foreach($companies as $company){
         $company_name = $company->post_title;
         echo $company_name;

    To target the first relationship in the array:

    $companiy = get_field('company');
    $company_name = $company[0]->post_title;
    echo $company_name;
  • Rolling your own field would probably be your best bet. Take a look at Awesome ACF. They have a lot of cool new fields to get you started. For what you’re looking for the Taxonomy Selector would be a good starting point. It has a method (get_taxonomies) that pulls current taxonomies into the custom field settings for selection.

Viewing 15 posts - 1 through 15 (of 15 total)