Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Check it out – just throw “old.” in front of the url to get to the old forums!

    http://old.support.advancedcustomfields.com/discussion/6459/restrict-post-object-selection-only-to-the-author

    Not sure about your actual question though… will get back to you on that one.

  • And NOW I found the solution on the documentation.
    Sorry. I’ll try to read first before I post again. 🙂

  • Sorry. Just had to use the same logic found on Customize the relationship field list query.

    Here’s the code:

    add_filter( 'acf/fields/post_object/query', 'change_posts_order' );
    function change_posts_order( $args ) {
    	$args['orderby'] = 'date';
    	$args['order'] = 'DESC';
    	return $args;
    }
  • Been xdebugging, and maybe this helps. core/fields/_functions.php:load_field( $field, $field_key, $post_id = false ) returns:

    $f = array[18]
    	$f['name'] = (string) dato
    	$f['class'] = (string) date_time_picker
    	$f['time_format'] = (string) H:mm
    	$f['field_group'] = (int) 6583
    	$f['conditional_logic'] = array[3]
    		$f['conditional_logic']['allorany'] = (string) all
    		$f['conditional_logic']['rules'] = array[1]
    			$f['conditional_logic']['rules'][0] = array[2]
    				$f['conditional_logic']['rules'][0]['operator'] = (string) ==
    				$f['conditional_logic']['rules'][0]['field'] = (string) null
    		$f['conditional_logic']['status'] = (int) 0
    	$f['show_week_number'] = (string) false
    	$f['value'] = <string>
    	$f['required'] = (int) 0
    	$f['type'] = (string) date_time_picker
    	$f['id'] = (string) acf-field-dato
    	$f['key'] = (string) field_51d520b7091da
    	$f['label'] = (string) dato
    	$f['picker'] = (string) slider
    	$f['show_date'] = (string) true
    	$f['order_no'] = (int) 0
    	$f['instructions'] = <string>
    	$f['save_as_timestamp'] = (string) true
    	$f['date_format'] = (string) m/d/y

    As you can see, the $f[‘value’] is empty

  • @wells5609 If you could help me a bit further, that would be great.

    I’m trying to connect my field group to a ajax filter plugin. It should be able to just put the field key in the shortcode and it should work but it does not so I’m trying to edit the plugin a bit. I’ve been able to show the correct field list in the plugin, but it does not show the counts or use the filter function..

    This is one part of the code (uag-wall-functions.php):

    if (strstr($key,'metakey')) {
    $matches = array();
    if (preg_match_all('/{([^}]*)}/', $value, $matches)) {
    		$i = 0;
    		foreach($matches[1] as $array) {
    		$i++;
    						
    	        $all_arg = explode(',', $array);
    		foreach($all_arg as $arg) {
    		$str_arr = explode(':', $arg);
    		$metakey[$i][$str_arr[0]] = $str_arr[1];
    		}
    						
    /* ARGS */
    $key = (isset($metakey[$i]['key'])) ? $metakey[$i]['key'] : null; 
    $field_key = (isset($metakey[$i]['field_key'])) ? $metakey[$i]['field_key'] : null;
    $title = (isset($metakey[$i]['title'])) ? $metakey[$i]['title'] : __('Untitled','uag');
    $reset_text = (isset($metakey[$i]['reset_text'])) ? $metakey[$i]['reset_text'] : __('Reset','uag');
    
    $metavalues = get_field_object($field_key);
    	if( $metavalues )
    		{
    $display .= '<div class="uag-filter" data-key="'.$field_key.'">
    											<div class="uag-filter-head"><span class="uag-toggle"></span>'.$title.'<div class="uag-helpers"><span class="uag-loading uag-hide"></span><a href="#" class="uag-reset">'.$reset_text.'</a></div></div>
    											<div class="uag-mainbody">
    												<div class="uag-filter-body">';
    											
    foreach($metavalues['choices'] as $metavalue) {
    $display .= '<a href="#" class="uag-filter-option" data-metakey="'.$field_key.'" data-metavalue="'.$metavalue.'">'.$metavalue;
    
    if ($args['count'] == 'show') {
    									$display .= '<span class="uag-count">'.uag_meta_count($field_key, $metavalue, $args).'</span>';
    		}
    	$display .= '</a>';
    		}
    												
    	$display .= '</div>
    									</div>
    								</div>';
    	}

    and the functions.php file:

    /* Collect meta values */
    	function uag_meta_values($metakey) {
    		global $wpdb;
    		$prefix = $wpdb->prefix.'postmeta';
    		$posts = $wpdb->prefix.'posts';
    		$values = $wpdb->get_col("SELECT meta_value AS $metakey FROM $posts 
    	JOIN $prefix ON ($prefix.post_id =  $posts.ID) 
    	WHERE post_status = 'publish' 
    	AND meta_key = '$metakey'");
    		$values = array_unique($values);
    		return $values;
    	}
    
    	/* Count */
    	function uag_count_meta_values($metakey) {
    		global $wpdb;
    		$prefix = $wpdb->prefix.'postmeta';
    		$posts = $wpdb->prefix.'posts';
    		$values = $wpdb->get_col("SELECT meta_value AS $metakey FROM $posts 
    	        JOIN $prefix ON ($prefix.post_id =  $posts.ID) 
    	        WHERE post_status = 'publish' 
    		AND meta_key = '$metakey'");
    		$values = array_unique($values);
    		return count($values);
    	}
    	
    	/* meta count by value */
    	function uag_meta_count($metakey, $metavalue, $args = null) {
    	$loop = array(
    	'post_type'	   => 'any',
    	'posts_per_page' => -1,
            'meta_key'	   => $metakey,
            'meta_value'     => $metavalue,
    
    		);

    Sorry, it’s a lot of code. But actually I’m not sure where to start in here. If you would point me in the good direction that would be enough. Thanks

  • Thanks for the response Elliot, unfortunately in our situation that did not solve the issue.

    Did some further testing (switching plugins themes) and eventually narrowed it down to an action hook for admin_enqueue_scripts. We load css on the backend for some of the content editor forms, and with the issue happening with ACFs enqueue’s we were able to finally find the issue.

    At the moment we’ve just commented out our own enqueue hook as we’re on the development server. Will provide the code of how we’re doing this, but we’ve never had an issue with this before (either with ACF nor other plugins).

    function load_theme_admin_scripts($hook) {
    	// Admin CSS
    	wp_enqueue_style('theme_admin_css', get_template_directory_uri() . '/library/css/admin_css.css', false, '1.0', 'all');
    
    }
    add_action( 'admin_enqueue_scripts', 'load_theme_admin_scripts' );
    
  • Hi @Elliot,

    url: "../wp-content/themes/twentytwelve/fields/test.php"

    I’ve done it this way indeed, I’m not using the native wp_ajax functions. So that would be the problem. I’ll find out how to do it correctly, thanks.

  • Thank you for your help

  • Just to give anyone who could search for this some extra informaiton, here was the exact sql statement

    “select * from wp_options where option_name like “%_category_%_start_date%”

    where start_date is the name of my field.

    Thanks again for your speedy answer.

  • Yep, you can jump over to the documentation page to view the actions / filters available.

    Or just use the search above for acf/save_post

  • Hi @guiloviu

    Looking at the code you have posted, there is clearly a problem with the way you have nested your arrays.

    For example, you have

    
    'relation' => 'AND',
    

    and

    
    'relation' => 'OR',
    

    in the same array.

    I think you should take another look at the WP_Query docs and also post this question on stack exchange as it does not involve any ACF specific functions.

  • Hi @jimmy.aat10

    In general, yes, it is possible to filter the posts shown in an ACF field.

    This said, I’m quite confused as to what fields you are using.

    Is the field a post object or relationship?
    Also, where would you want to add a column? TO what interface? Perhaps use a screenshot to demonstrate

  • My apologies, my head is wrapped around my goal. The access_pin is just a field that will be unique to a specific category. Do you have any examples of using the save_post action?

  • Thanks Elliot.

    Yes, this would be quite an advanced feature, but something to think about.

    Yes the subfields have different values.

    I have managed to find a solution, I created a page with the repeater sub-fields laid out. I saved that page without a title and then use a plugin to duplicate it whenever I need a new page with those same repeater subfields already there.

    I just think this would be a good feature as sometimes you have a lot of repeater subfields (like dropdown boxes with set values) that you use almost every time. A feature like this would ensure that they’re already setup when you create a new post.

  • Thanks Elliot, I was able to do that last night and it seems to work quite well

  • Hi @LeffDesign

    In your above code, you have the AJAX call pointing to:

    
    url: "../wp-content/themes/twentytwelve/fields/test.php",
    

    Is this correct? If so, WP will not be loaded correctly, ACF will not be included and your PHP error will make sense.

    In your first code however, you write that you are using the native wp_ajax functions.php AJAX solution.

    Can you confirm which way you are coding as they dramatically will effect ACF’s usage

  • Hi @Steve Holland

    This is not possible via the get_field function in ACF.

    I would encourage you to look at writing a custom sql query to find all these values

    Thanks
    Elliot

  • Reading over your topic again, I may have miss understood the feedback.

    I wonder if you could use the save_post action to first check that the values posted are unique. If not, you could then redirect the browser or find another way to abort the save.

  • Hi @rddesigns

    Sorry, I don’t understand what you mean by ‘access pin’. Would you mind elaborating more on this and why it would be useful?

  • Hi @Steve Holland

    Thanks for the request. This isn’t as easy as you may think to add in.

    Would the ‘x’ number of rows contain different default values in the sub fields?

  • Hi @edir

    Thanks for the feedback.

    Currently this is not possible unless you were to edit the core files of the options page add-on.

    I will add this request to the to-do and hopefully see it released in an update soon

    Cheers
    Elliot

  • ok Elliot, thanks but…
    it gets this :

    array(2) {
      [0]=>
      string(2) "en"
      [1]=>
      string(2) "fr"
    }

    How tests “en” checkbox is checked and test “fr” is checked ?

  • This sounds like more of an HTML issue than something to do with ACF.
    If links are opening in a new window, you probably have target=”_blank” on the anchor element, right? To get an overlay would depend on your HTML/CSS/JS setup. For example, if you’re using Twitter Bootstrap, this would be done by setting data-toggle=”modal” and data-target equal to the modal div selector (which would have the video as its content).

  • @mikosworld,

    Try this:

    $lang = get_field('language');
    	
    if ( 'en' === $lang ) { 
    	echo "ENGLISH Flag icon"; 
    }
    elseif ( 'fr' === $lang ) { 
    	echo "FRENCH Flag icon"; 
    }
    
  • @elliot,

    I’m liking the typeahead on users and tags.

    Another possible feature – the ability to view only unread/unsolved (question) topics?

Viewing 25 results - 21,301 through 21,325 (of 21,363 total)