Support

Account

Forum Replies Created

  • From what I have tested, no ACF fields are showing in the Product (custom post type).

  • I don’t understand what kind of notification you want to display/trigger, but you could use the update_value filter to check the difference before saving the new values and notify the way you want on removed/added differences.

    function relation_field_update( $value, $post_id, $field  ) {
        if (wp_is_post_revision( $post_id )) return $value;
    
        $old_values = get_field($field['name']);
        $added = @array_diff($value, $old_values);
        $removed = @array_diff($old_values, $value);
    
        return $value;
    }
    
    add_filter('acf/update_value/name=relation_field', 'relation_field_update', 10, 3);
    

    Where name=relation_field in the filter is the name of the ACF field you want to verify.

    The wp_is_post_revision check is necessary since you don’t want to verify post revision. The @ are there to bypass the exception threw when one of the array is null (this could be done better with condition, e.g. is_array()).

    So, $added will be (empty or) containing the added IDs and $removed will be (empty or) containing the removed IDs.

  • Check this: How to add ACF to WordPress search/Relevanssi

    Also, Relevanssi will normally search in the post title. But you have to specify the custom fields’ names (those used with ACF) in the Relevanssi settings.

  • That is because on the site side, ACF will not apply the conditional logic (only in the admin side). You need to do it by “yourself” using normal PHP condition, just like this:

    if (get_field('credentials') == 'expired') the_field('credentials_expired_date');

    This way, the credentials expired date will only be displayed if the credentials field is set to ‘expired’.

    ACF is not applying the condition when displaying the data on the site and it is perfect like this. It is up to you (your code, I mean) to choose if you want or not to display that date (also, the ACF conditional logic doesn’t affect if the ‘credentials_expired_date’ is stored or not, it is only affecting the displaying of the field in the admin area).

  • Ok, sounds better.
    Here is some code (with no html format) to help you sort this out:

    
    <?php
    $args = array(
    	'orderby'=>'nicename', 
    	'role'=>'subscriber'
    );
    
    $users = get_users( $args );
    
    foreach ( $users as $user ) {
    	print($user->display_name);
    	the_field('years_of_experience', 'user_'.$user->ID);
    	the_field('credentials', 'user_'.$user->ID);
    }
    ?>
    
    

    The role must be the one your Instructors will get.

    You need to put that in a template (author.php or a page template) in your custom theme.

    Useful references:

  • Like this:

    $roles = array('Director', 'Lead Teacher', 'Teacher', 'Assistant Teacher');
    Also, roles could be populated from a taxonomy or from a custom post type.

    Then:

    
    $location = ''; // to be defined
    $facultys = array();
    
    foreach($roles as $role) {
    	$posts = get_posts(array(
    		'post_type’ => 'faculty’,
    		'order’ => 'ASC’,
    		'meta_query’ => array(
    			array(
    				'key’ => 'location’,
    				'value’ => $location,
    				'compare’ => 'LIKE’,
    			),
    			array(
    				'key’=> 'role’,
    				'value’ => $role,
    				'compare’ => 'LIKE’,
    			)
    		)
    	));
    
    	// Merge the posts result with the existing facultys
    	$facultys = array_merge($facultys, $posts);
    }
    
    
  • It would be this way (notice the orderby and meta_key properties):

    
    $facultys = get_posts(array(
    	'post_type’ => 'faculty’,
    	'order’ => 'ASC’,
    	'orderby' => 'meta_value', 
    	'meta_key' => 'role'
    	'meta_query’ => array(
    		array(
    			'key’ => 'location’,
    			'value’ => ”,
    			'compare’ => 'LIKE’,
    		),
    		array(
    			'key’=> 'role’,
    			'value’ => ”,
    			'compare’ => 'LIKE’,
    		)
    	)
    ));
    
    

    But, it seems that you want to order the post in a specific custom order which is not alphabetical or numerical (I’m saying that because ‘Assistant Teacher’ is after ‘Teacher’, while the rest are in a alpha order). In that case, you should create four get_posts queries (it could be the same in a loop, only changing the role value), each query with the specific role.

    More useful info

  • To output in the desired format, just use the PHP function number_format.

    
    $feet = get_field('feet');
    echo number_format($feet, 2, '.', ',');
    
  • You could use the ACF Repeater field which will contains multiple rows of the ACF Post Object field (or Page Link field) combined with others ACF fields like the price, etc.

    Otherwise, I’m also a longtime user of ACF, but when it comes to create link between posts together (they could be bi-directional, which is not possible at first with ACF) I still prefer the Posts 2 Posts plugin with which you can also add specifics fields (not ACF ones) in the relation between the two posts.

  • The Home page default template is the home.php located in your custom theme directory. If it doesn’t exists, just create that file with the proper name “home.php”. Otherwise, you can create a custom template with whatever name (except those reserved by the WordPress hierarchy, but you need to make that file a template), create a page in the WordPress admin which will use that template and then configure WordPress to display that static page as the home page.

    Other reference which could be useful: http://www.wpbeginner.com/wp-themes/how-to-create-a-custom-homepage-in-wordpress/

    But you want your home page to display the users list showed with their related ACF custom fields, that’s it?

  • You need to use the edit_attachment action to save those custom fields.

    add_action( 'edit_attachment', 'my_save_attachment_location' );

    Just tested it and it works, wasn’t working with attachment_fields_to_save filter.

    
    function my_add_attachment_location_field( $form_fields, $post ) {
        $field_value = get_post_meta( $post->ID, 'location', true );
        $form_fields['location'] = array(
            'value' => $field_value ? $field_value : '',
            'label' => __( 'Location' ),
            'helps' => __( 'Set a location for this attachment' )
        );
        return $form_fields;
    }
    add_filter( 'attachment_fields_to_edit', 'my_add_attachment_location_field', 10, 2 );
    
    function my_save_attachment_location( $attachment_id ) {
        if ( isset( $_REQUEST['attachments'][$attachment_id]['location'] ) ) {
            $location = $_REQUEST['attachments'][$attachment_id]['location'];
            update_post_meta( $attachment_id, 'location', $location );
        }
    }
    add_action( 'edit_attachment', 'my_save_attachment_location' );
    

    Source

  • ok ok, sorry for that I wish I could help you… that’s it.
    Hopefully for me, I’m a paying user just like you trying to make ACF better.

    Good luck then.

  • This reply has been marked as private.
  • I would rather use the acf/save_post action (and not transition_post_status) as described here: http://www.advancedcustomfields.com/resources/acfsave_post/

    This should solve your issue. If the die() is acting like this, it is because there is normally others actions taking place after the transition_post_status action, so when you script dies, you are only cancelling what is following (and what is following is putting back your data to the original posted values).

  • I saw your thread and all of them were answered, except one which was a minor issue. Two others threads not marked as solved were answered directly by Elliot, who is the main developer of ACF, you could not ask better.

    In one case Elliot just said he added your solution to his todo.
    And on the other he saw the bug and asked why WPML was reacting this strange way, did you write to WPML to check about that? Are you sure there is no workaround to solve your specific issue?

    I know ACF since it started, it is a big project, indeed, but as far as I know it’s one of the best plugin I ever saw (remember that it was free until version 5).

    Nothing’s perfect, I understand it is bad to be confronted to new bug on new release. Also, WPML is particularly a huge project, which it makes difficult to assure 100% compatibility with.

  • This is not related with Php, but with the template hierarchy in WordPress.
    You need to understand how WordPress works and how to develop a theme to do so.

    I’m not sure if you are talking about the WordPress’ users or you are asking about a custom members listing. If it is the second choice it will be good to take a look at how to create a custom post type (members) and how to build the front-end page for it (archive-members.php and single-members.php).

    Those are just cue, since I cannot explain everything about WordPress here.

  • Check that: http://www.advancedcustomfields.com/resources/shortcode/

    But if I were you I would not use shortcode. Instead, I will create the author template in my custom theme (author.php) and populate it with the needed fields.

  • Use a custom script to validate and enqueue it with: acf/input/admin_enqueue_scripts

    I doubt we can help you furthermore unless your clarify your needs; what kind validation, since ACF already has some sort of validation; do you need it live (with JS) or after the publishing step, etc.

  • Where and what are your requests?

    The forum threads are made for that, that is where you should rely on.

  • I could not see anything simpler than the_field() or get_field(). You should not bypass that point without cleaning your script.

    You should test (in the top of the script or the loop) if the related post in the single post page has the ‘parent_series’ set:

    <?php
    die(get_field('parent_series');
    ?>

    Or maybe your problem is simply related with a misunderstanding of the WordPress loop which could easily leads to strange behaviour like the one your are talking about.

  • You can achieve that using this WordPress function: get_attached_file

    $file_id = get_field('file');
    
    $filedir = get_attached_file( $file_id );

    Don’t forget to specify the return type of the acf field to ID. Otherwise, just change your code accordingly:

    $file_arr = get_field('file');
    
    $filedir = get_attached_file( $file_arr['id'] );
  • Try this instead:

    	if( function_exists('acf_add_options_page') ) {
    		
    		acf_add_options_page(array(
    			'page_title' 	=> 'Options',
    			'menu_title'	=> 'Options',
    			'menu_slug' 	=> 'options',
    			'capability'	=> 'edit_posts',
    			'redirect'	=> false
    		));
    		
    		acf_add_options_sub_page(array(
    			'page_title' 	=> 'Page 1',
    			'menu_title'	=> 'Page 1',
    			'parent_slug'	=> 'options',
    		));
    		
    		acf_add_options_sub_page(array(
    			'page_title' 	=> 'Page 2',
    			'menu_title'	=> 'Page 2',
    			'parent_slug'	=> 'options',
    		));
    	
    	}

    Not need for an action hook.
    Source: http://www.advancedcustomfields.com/resources/acf_add_options_page/

  • Same here.

    Uncaught TypeError: Cannot read property ‘attributes’ of undefined

Viewing 25 posts - 1 through 25 (of 31 total)