Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • K, sorry, I must be missing somehting. Here’s my code that doesn’t seem to work.

    function my_acf_save_post( $post_id )
    {
    	// vars
    	$fields = false;
     
    	// load from post
    	if( isset($_POST['fields']) )
    	{
    		$fields = $_POST['fields'];
    		
    		// concert details
    		
    		// event start date
    		//$fields['field_5217ac66687dc']
    		// event end date
    		//$fields['field_524b4ca5ff418']
    		
    		if( empty( $fields['field_524b4ca5ff418'] ) )
    			$fields['field_524b4ca5ff418'] = $fields['field_5217ac66687dc'];
    		
    		// calendar details
    		
    		// event start date
    		//$fields['field_524b4c06af2a2']
    		// event end date
    		//$fields['field_524b4c3aaf2a4']
    		if( empty( $fields['field_524b4c3aaf2a4'] ) )
    			$fields['field_524b4c3aaf2a4'] = $fields['field_524b4c06af2a2'];
    	}
     
    	// ...
    }
     
    // run before ACF saves the $_POST['fields'] data
    add_action('acf/save_post', 'my_acf_save_post', 1);
  • Np Kyle,

    you wont have to worry about the field keys tho, they’re actually the ones you really should use since they will never change and are 100% unique compared to field names which depends on the developers paranoia 😉 (I myself always write custom fields like “acf_reference_name” since I want to be 500% sure it would never collide).

  • Hi Elliot,

    Thanks so much for your help.

    My mySQL storage service seems to be unlimited.
    I know this mgith be a non-ACF related question..
    but is there a way to check maxvars limit in phpMyAdmin?
    Where should I look into?

    The reason why I chose this data structure is that I have more than 300+ items and each of them has relatively short information.
    I didn’t want 300+ posts/pages in my page list.

    Please let me know if you have any other idea.

    Thanks a lot!

  • Sorry I’m quite new to wordpress so maybe I don’t use the right words.

    In my case I register 2 custom taxonomies by diong this:

    register_taxonomy('genres_bdd', 'bdd',array('hierarchical' => false, 'label' => 'Genres', 'query_var' => true, 'rewrite' => true));
    register_taxonomy('categories_bdd', 'bdd',array('hierarchical' => true, 'label' => 'Catégories', 'query_var' => true, 'rewrite' => true));

    Let’s say that the taxonomy “Manga” in my location rule belongs to “categories_bdd”.
    The taxonomy field in my field group populate with the value from the taxonomy “Genres”.

    Then if I write a post with the taxonomy “Manga” my field group appears: normal.
    But then if I check one value in the taxonomy field inside the field group, it hides.

  • Hi @dahousemix

    What do you mean by “taxonomy group or tag. I suggest it search only for a tag change.”.

    I don’t quite understand these terms.

    Thanks
    E

  • Hi @sKuijers

    The acf_form_head function is only intended to be used in a front end template. It can’t be used in the backend in the same way.

    For ACF to work, you will need to use the acf/input/head, acf/input/enqueue_scripts actions. Perhaps you could look in the core/controllers/input.php file to see how ACF adds the necessary code to the post page?

    Thanks
    E

  • Hi @sleepydada

    1. What is the return type for the image field?
    2. Where are you using this code? Can you provide full context (eg: wrapping element?)
    3. What is 80?

    All pages? You will need to get these ID’s from a WP query (get_posts) and then loop through them to output the image element.

    Thanks
    E

  • Jonathan, thanks for the response. I guess I just need to manipulate the field keys then and ACF does all the heavy lifting in the back end then.

    I was just worried that the field keys were dynamic and would change. That’s why I was looking for the actual key names created such as mom_event_date”

    I’ll give that a try and see how it works.

  • Hi. Sorry for getting this up. But I have found in the same situation where I need 2 levels for Select field.

    In my case, I wanted to use the interface to do that, so I have made a change in my ACF select field code to permit that. If the line in the interface starts with – (for instance -Europe ) it will assume there are optgroups, so everything that comes after that line will be for that group until next – is found.

    In my case, in the interface I write:

    -Europe
    Spain
    France
    -America
    Argentina
    Peru

    and then I get a select with optgroup where Europe and America are the group headlines and the rest are the selectable options.

    In advanced_custom_fields/core/fields/select.php LINE 68 add

    		// Other way to group is using - in the field
    		if (!$optgroup) {
    		// vars
    		$new_choices = array();		
    			// Determine if there are - to group the field
    			$group = false;
    			$choices_group = array();
    			$optgroup_key = "";
    			foreach ($field['choices'] as $k => $v) {
    				if (strpos($v, "-") !== false)
    				{
    					// Next elements are optgroup;
    					if ($group) {
    						$choices_group [$optgroup_key] = $new_choices;
    						$new_choices = array();
    						$optgroup_key = $v;
    					} else {
    						
    						// Get ungrouped value from begining of the list
    						foreach ($new_choices as $l=>$w) {
    							$choices_group[$l] = $w;
    						}
    						$new_choices= array();
    						
    						$group = true;
    						$optgroup_key = $v;
    
    					}
    				} else {
    					if(strpos($v, ' : ') !== false)
    					{
    						$choice = explode(' : ', $v);
    						$new_choices[ trim($choice[0]) ] = trim($choice[1]);
    					}
    					else
    					{
    						$new_choices[ trim($v) ] = trim($v);
    					}
    					
    				}
    			
    			}
    			if ($group) {
    				// End last group
    				$choices_group [$optgroup_key] = $new_choices;
    				$field['choices'] = $choices_group;
    				$optgroup = true;
    			}
    		}		
    
    
  • Hi!

    I believe the field_524b4c06af2a2 is the field key for one of your fields. you can open up the panel settings when on the edit page of the field group and check to show field keys and you’ll see which ones you should work with.

  • Hey Elliot,
    Thanks for the prompt reply. This is just a function I’m running that pulls a field from the image/attachment meta. So it would be the page.php template, I suppose. This is a genesis child theme, too, if that helps.

    In the function I didn’t declare the global $post variable originally, but I did just now and it didn’t seem to change anything. I tried getting the field using the_field() method and also as a variable and neither seemed to work.

    Here’s teh function in full, don’t mind the ugly code. =)

    add_action( 'genesis_before_loop', 'ds_add_featured_image', 1 );
    function ds_add_featured_image() {
    	global $post;
    	$variable = get_field('featured_image_link');
    	?>
    
    	<div class="featured-image">
    		<a href="<?php get_field( $variable ); ?>" title=""><?php the_post_thumbnail(); ?></a>
    		<span class="caption"><?php  get_post( get_post_thumbnail_id() )->post_excerpt;?> </span>
    	</div>
    
    <?php }
    
  • Hi @sasori390,

    I think this should just about do it.. this can be used outside of the loop which I assume you are doing. If not you could probably remove the global $post.

    
    <?php
    global $post;
    if($post->post_parent){
    	$postid = $post->post_parent;
    }else{
    	$postid = $post->ID;
    }
    ?>
    
    <?php if(get_field('content-container', $postid)): ?>
    <ul>
    	<?php while(has_sub_field('content-container', $postid)): ?>
    	<li><a href="<?php the_permalink() ?>#<?php the_sub_field('anchor'); ?>"><?php the_sub_field('header'); ?></a></li>
    	<?php endwhile; ?>
    </ul>
    <?php endif; ?>
    
    
  • Hi @christopher88

    Am i right in assuming that you are using the post_object field? Is this setup as a single or multiple select field?

    Have you tried printing the returned value of get_field()?

  • Hi @filogti

    No worries. ACF is really just a UI for the native custom fields in WP. Therefore, you can use all the functions that WP offer to query posts in the DB based on custom fields.

    You should take a look at the get_posts function. It uses the same args as the WP_Query object and allows you to query the database.

    Good luck

    Cheers
    E

  • How strange. Looks like the args are correctly being set,

    Your next step is to find out why the args aren’t being read in by ACF by running a simple debug in the ACF code.

    Edit the core/fields/post_object.php file and on line 171, can you print out the $args? Are the args taking ont he changes from your filter?

    Thanks
    E

  • OK, so I can set the key field myself and it can be whatever I want it to be as long as it’s unique in the database? That’s perfect. Thanks!

  • Thanks for your reply Jonathan/Elliot.

    Sorry if my question is confusing. I’m essentially trying to wp query the field. For example, if I was making a simple query to a text field, I would do it like so:

    new WP_Query(array(
    	"meta_key" => "animal",
    	"meta_value" => "cat"
    ));

    But is there a way to query against the associated post? So if I knew post X’s associated ID and I wanted to get all posts associated with post X, how would I go about it?

    Thank you very much for your help.

    Chris

  • Hi elliot,

    Here the $args

    Array
    (
        [numberposts] => 7
        [post_type] => emission
        [orderby] => date
        [order] => date
        [post_status] => publish
        [suppress_filters] => 
        [sort_column] => date
        [sort_order] => DESC
    )
  • Ok, seems that a call to wp ajax into the functions.php caused the problem.

    I had this code into functions.php used to process data for a form:

    // this hook is fired if the current viewer is not logged in
    	do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );
    	// if logged in:
    	do_action( 'wp_ajax_' . $_POST['action'] );
    	add_action( 'wp_ajax_nopriv_gfl', 'gfl' );
    	add_action( 'wp_ajax_gfl', 'gfl' );
    	function gfl() {
    		if (isset($_POST['id'])){
    	        $id = $_POST['id'];
    	        $tr_type = get_tr_type($id);
    	        echo $tr_type;
    	    }else if(isset($_POST['to_id'])){
    	        $id = $_POST['to_id'];
    	        $tr_type = get_tr_type($id);
    	        echo $tr_type;
    	    }
    		exit;
    	}
    	add_action( 'wp_ajax_nopriv_gtl', 'gtl' );
    	add_action( 'wp_ajax_gtl', 'gtl' );
    	function gtl() {
    		$from_id = $_POST['id'];
    	    $to_id = $_POST['to_id'];
    	    get_to_locations($from_id,$to_id);
    		exit;
    	}

    Now i’ve wrapped this code between an is_admin() condition:
    if (!is_admin()) { // Ajax Code }

    Seems that the location is now working well.

  • Hi @chriscarvache

    It is possible that your issue is a unique one. Are you able to turn on DEBUG MODE in your wp-config.php file, then jump back to the front end form and refresh your browser, open up your console log and test the upload again.

    After the image fails to upload, you should see the ajax call in the console log and you can review the returned HTML. What are the error messages?

    Thanks
    E

  • Hi @christopher88

    Can you provide some context? Are you aware of the get_field function and that it will return a formatted value based on the field type.

    For example, if you use get_field to load a post_obect field value, it will return 1 or more post objects.

    Hope that helps.

    Thanks
    E

  • Hi @Dilldoy

    The repeater field should have an updtae sometime int the next few weeks containing the new update file which can be removed from the plugin.

    With the update script removed, you can including the add-on within your premium theme / plugin

    Thanks
    E

  • Hi @Romain9p

    Can you debug your filter by running this code before returning the $args:

    
    echo '<pre>';
    	print_r($args);
    echo '</pre>';
    die;
    

    Do you see the array printed?

  • with “a-tag” im just referring to a regular anchor.

    You could put a hmtl field at the end of the repeater-row with:

    
    <a href="#" class="open-imglatlon">Set image coordinates</a>
    

    and then in your javascript you trigger the popup when user clicks open-imglatlon

    
    $('.open-imglatlon').click(function(e){
    e.preventDefault(); //this prevents regular link-click. 
    });
    
    
  • I was able to figure it out thanks to this:http://wordpress.stackexchange.com/questions/78826/inserting-gravity-form-checkbox-values-into-advanced-custom-fields

    One thing I ran into is that if I needed the serialized value for a field, the “get_post_custom_values” function worked. Otherwise, the ACF “get_field” function was what I needed for other types of fields.

    add_action("gform_after_submission_2", "acf_post_submission", 10, 2);
    
    function acf_post_submission ($entry, $form)
    {
    	$post_id = $entry["post_id"];
    	
    	// funding status
    	$values = get_field("reviewer_funding_status", $post_id); 
    	echo "<br />reviewer_funding_status: " . $values;
    	update_field("field_519f97aab12f7", $values, $post_id);
    			
    	// rating - overall
    	$values = get_field("rating_overall", $post_id); 
    	echo "<br />rating_overall: " . $values;
    	update_field("field_519f989ab12f8", $values, $post_id);
    	
    	// rating - clarity of mission
    	$values = get_field("rating_clarity_of_mission", $post_id); 
    	echo "<br />rating_clarity_of_mission: " . $values;
    	update_field("field_520be9eac3f72", $values, $post_id);
    	
    	// rating - communications
    	$values = get_field("rating_communications", $post_id); 	
    	echo "<br />rating_communications: " . $values;
    	update_field("field_519f98d4b12f9", $values, $post_id);
    	
    	// rating - evaluation
    	$values = get_field("rating_evaluation", $post_id); 
    	echo "<br />rating_evaluation: " . $values;
    	update_field("field_520be9fdc3f73", $values, $post_id);					
    	
            // funder ID
    	$values = get_post_custom_values("funder_id", $post_id);
    	echo "<br />funder_id - serialized: " . $values;	
    	update_field("field_519f996ce16ca", $values, $post_id);
    }
Viewing 25 results - 20,351 through 20,375 (of 21,339 total)