Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • The code above was missing the $match rules so although you could see the correct pages in the location rules, the ACF rule wouldn’t get applied to anything. This should work:

    /*
    * ACF post parent
    */
    
    add_filter('acf/location/rule_types', 'acf_location_rules_types');
    function acf_location_rules_types( $choices )
    {
        $choices['Custom Post types']['cpt_parent'] = 'Custom post type parent';
     
        return $choices;
    }
    add_filter('acf/location/rule_values/cpt_parent', 'acf_location_rules_values_cpt_parent');
    function acf_location_rules_values_cpt_parent( $choices )
    {
    	$args = array(
    		'hierarchical' => true,
    		'_builtin' => false
    	);
        $posttypes = get_post_types( $args );
     
        if( $posttypes )
        {
            foreach( $posttypes as $posttype ):
            
    			if( $posttype != 'acf' ):
    				$args = array(
    				'post_type' => $posttype,
    				'posts_per_page' => -1,
    				'post_status' => 'publish'
    				);
    				$customposts = get_posts( $args );  
    				if ( $customposts  ) {
    					foreach( $customposts as $custompost ){
    						$choices[ $custompost->ID] = $custompost->post_title;
    					}
    				}
    			endif;
    		endforeach;
    	}
     
        return $choices;
    }
    
    //MATCH THE RULE
    add_filter('acf/location/rule_match/cpt_parent', 'acf_location_rules_match_cpt_parent', 10, 3);
    function acf_location_rules_match_cpt_parent( $match, $rule, $options )
    {
    	
    	global $post;
    	$selected_post = (int) $rule['value'];
    
    	// post parent
    	$post_parent = $post->post_parent;
    	if( $options['page_parent'] ) {
    	
        	$post_parent = $options['page_parent'];
        	
    	}
    
    	if ($rule['operator'] == "=="){
    		$match = ( $post_parent == $selected_post );
    	}
    	elseif ($rule['operator'] != "!="){
    		$match = ( $post_parent != $selected_post );
    	}
     
        return $match;
    }
  • I’m using this function to convert the string and use the special chracters which the dropdown selector is having problems. Hope this can be fixed soon:

    function select_wsafe_font($fs) {
        if ($fs == "arial_bla") $fs = "'Arial Black', sans-serif";
        if ($fs == "arial_hel") $fs = "Arial, Helvetica, sans-serif";
        if ($fs == "centh_got") $fs = "Century Gothic, sans-serif";
        if ($fs == "couri_new") $fs = "'Courier New', Courier, monospace";
        if ($fs == "georgia") $fs = "Georgia, Serif";
        if ($fs == "impact") $fs = "Impact, Charcoal, sans-serif";
        if ($fs == "lucid_san") $fs = "'Lucida Sans Unicode', 'Lucida Grande', sans-serif";
        if ($fs == "palatino") $fs = "'Palatino Linotype', 'Book Antiqua', Palatino, serif";
        if ($fs == "tahoma") $fs = "Tahoma, Geneva, sans-serif";
        if ($fs == "times_new") $fs = "'Times New Roman', Times, serif";
        if ($fs == "trebuc_ms") $fs = "'Trebuchet MS', Helvetica, sans-serif";
        if ($fs == "verdana") $fs = "Verdana, Geneva, sans-serif";
        // Google Fonts
        echo $fs;
    } // END Selector Web Safe Font
  • I have solved this. It was my mistake.

    I should have been using:

    Show this field group if Logged in user is equal to Administrator

  • Hi Elliot, finally I get the data from the array in this way:

      if( is_array($checkbox_options)&& in_array( 'show_grid_bp', $checkbox_options ) ) {
        echo "border-right:dotted 1px black;";
        } else {
        echo "border:none;";}

    , I still don’t understand very well the docs, could you use the data above and use your code, so I can see?

  • Okay, the mystery…er..a workaround for this was found by a co-worker of mine.
    Firs the fix and then some details in case acf folks need some variables for bug fixing.

    Workaround
    Our WYSIWYG fields were set to ‘basic’. When they were set to ‘full’ all of a sudden the div’s mentioned above in the first post showed up in the text editor tab. Which they hadn’t in the text editor tab in the ‘basic’ editor.
    Deleting the opening and closing divs fixed it.

    Debugging Details

    • Our acf field was always ‘basic’ from the get go.
    • Our acf field group which held the wysiwyg was added to pages that already existed, er, meaning it was saved already with other acf fields.
    • The extra div’s never showed up in the db’s post_meta rows/fields. I checked.
    • It seems to happen only the first time the page is saved after a the acf fields are added to it. ? I think?
    • I also did two quick new pages and wasn’t able to reproduce it on new pages that had never been saved before. Hardly thorough, but maybe there’s something there
    • The extra div’s didn’t show up in all repeating fields on a first save, I couldn’t ever figure out why some did and some didn’t.

    Here’s a sample of what the div’s looked like in the editor. Note there’s more than one set in this one. Not the case for all examples.

    <div class="page" title="Page 13">
    <div class="section">
    <div class="layoutArea">
    <div class="column">
    
    <strong>A call to action (with a little humor)</strong>
    
    </div>
    </div>
    <div class="layoutArea">
    <div class="column">
    
    “On paper, Toxoplasma gondii looks as if it ought to be the most famous parasite on earth. This single-celled pathogen infects over half the world’s population, including an estimated 50 million Americans. Each of Toxoplasma’s victims carries thousands of the parasites, many residing in the brain. As if that were not enough
    of an accomplishment, Toxoplasma is equally adept at infecting all other warm-blooded animals, as disparate as chickens and kangaroos.”
    
    Opening paragraph of “A Common Parasite Reveals Its Strongest Asset: Stealth” By Carl Zimmer, The New York Times, June 20, 2006
    
    This is his conclusion:
    
    “Dr. Milton M. McAllister, a parasitologist at the University of Illinois at Chicago, has called for controlling the spread of Toxoplasma by cats. He notes that oocysts from cats can also infect wildlife. Toxoplasma has even been detected in sea otters, suggesting it can reach the ocean.
    
    ‘It’s perfectly safe to keep a cat,’ he said. ‘Just keep it inside.’”
    
    &nbsp;
    
    <strong>How does this change your view of things?</strong>
    
    “On Oct. 16, 2002, at 4 p.m., I walked out of my apartment in Secunderabad, India, leaving the door wide open, the lights on and my laptop humming. I don’t remember doing this. I know I did it because the building’s night watchman saw me leave. I woke up the next day in a train station four miles away, with no idea who I was or why I was in India. A policeman found me, and I ended up strapped down, hallucinating in a mental hospital for three days. ”
    
    Opening paragraph of “Crazy Pills” By David Stuart MacLean, New York Times Op-Ed, August 7, 2013.
    
    His conclusion:
    
    “Lariam is a drug whose side effects impair the user’s ability to report those side effects (being able to accurately identify feelings of confusion means that you probably aren’t that confused). The side effects leave no visible scars, no objective damage. But if Lariam were a car, if psychological or neurological side effects were as visible as broken bones, it would have been pulled from the market years ago.
    
    It’s a prescription I wish I had left unfilled.”
    
    </div>
    </div>
    </div>
    </div>
  • Hi guys

    The issue is due to the field name length. Solution below:
    http://www.advancedcustomfields.com/faq/field-value-wont-save/

    Thanks
    E

  • Hi @netsimp

    You have answered the question your self. The plugin is needed for the fields to show. If the plugin wasn’t needed, it wouldn’t exist in the first place.

    Thanks
    E

  • Hi @Rai Uriarte

    1. You can get the date picker value like so: get_field('field_name')
    http://www.advancedcustomfields.com/resources/get_field/

    2. You can get the current date like so:
    http://php.net/manual/en/function.date.php

    3. You can compare them like so:
    http://stackoverflow.com/questions/8722806/how-to-compare-two-dates-in-php

    Hope that helps

    Cheers
    E

  • Hi @fabian

    Please keep in mind this is a community forum, not a support desk. If you wish for one on one support, please email us here: http://support.advancedcustomfields.com/

    As for you question, the radio button is not a type of input which can allow a null value. It was a mistake for it to ever allow such behavior.

    The acf/validate_value filter can be used on any value to return a customized validation result which is performed on submission of the post and displayed via AJAX.

    Does that help?

  • If I understand the question correctly, if you’re using multiple custom field groups on the same page/post type it seems that the Hide Content Editor box needs to be checked for each of them.

  • Hi @kkyang

    Yep, the length can cause WP not to save. Described here: http://www.advancedcustomfields.com/faq/field-value-wont-save/

  • Hi guys

    Thanks for the request. Can you provide a snippet from other plugins, I would liek to keep this consistent with everyone else.

    I’m guessing it is a constant in the wp-config.php file?

  • Hi @Dmitry Averin

    I’m sorry but I don’t quite understand your question.
    What do you mean by:
    – Posting from the front-end to the certain category of WP working good, I did it.

    What code are you using to save the term data to the created post?

  • Hi @vicky8394

    Just to clarify for future readers:
    You are using the taxonomy ‘category’ with a custom field (taxonomy) to select multiple ‘brands’, where ‘brand’ is a taxonomy type.

    You care now trying to query the DB for all categories which contain a brand value.

    The problem here is that WP does not offer a termeta table (like postmeta) and doesn’t offer any functions to query terms via a custom field.

    ACF saves term custom field values into the wp_options table which makes it very hard to query.

    Unfortunately, you can’t join the tables together due to the way the data is saved, and you will need to consider 1 of these 2 options:
    1. Change your ‘category’ from a taxonomy to a post_type. This will allow for much simpler querying
    2. Load all categories, and then loop over them, load the ACF data for each (get_field) and use PHP to compare the data. This is not very efficient but will work

    Thanks
    E

  • Hi @richimgd

    This isn’t currently possible, but it would be quite simple to write some JS to do add another button to each layout and add in the duplicate functionality. If you wish to do this, p[lease dive into the pro/js/pro-input.js file and look at the acf.fields.flexible_content object and all it’s functions.

    Otherwise, you will need to take the manually approach of adding a layout and then copy / paste the values across from one layout to another.

    I can’t imagine why you would need to duplicate content in an email. Can you provide an example of when you would duplicate a layout including the values?

  • Hi @donaldG

    I’ll answer your questions one by one:

    1. ACF4 and ACF5 store field data in different DB locations
    2. Upgrading from v4 to v5 will launch a migration tool which will copy the data to the new location.
    3. All v5 editing will not effect the old v4 data
    4. Any fields created in either v4 or v5 can be exported to PHP and will work in both versions!

    Cheers
    E

  • Hi @jquesada

    Perhaps the 3rd party plugin does not offer support for ACF PRO?

    I hope that you can find a solution with the qTranslate developers

    Thanks
    E

  • This is currently working on a custom post type for me.

    /**
     * Front end creation of new download
     * @author  Mike Hemberger
     * @link http://thestizmedia.com
     * @uses Advanced Custom Fields Pro
     */
    add_filter('acf/pre_save_post' , 'jivedig_newdownload_pre_save_post' );
    function jivedig_newdownload_pre_save_post( $post_id ) {
    
    	// check if this is to be a new post
        if( $post_id != 'new' ) {
            return $post_id;
        }
    
        // Create a new post
        $post = array(
    		'post_status' => 'publish',
    		'post_title'  => $_POST['acf']['field_5483b32a04842'], // beat_title
    		'post_type'   => 'download',
        );
    
        // insert the post
        $post_id = wp_insert_post( $post );
    
    	// update $_POST['return']
        $_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
    
        // return the new ID
        return $post_id;
    
    }
  • Figured it out on my own. Putting this here in case it helps someone. The following uses both a repeater field and flexible content in the widget.

      function my_dynamic_sidebar_params( $params ) {
        
        // get widget vars
        $widget_name = $params[0]['widget_name'];
        $widget_id = $params[0]['widget_id'];
        
        
        // bail early if this widget is not a Text widget
        if( $widget_name != 'Text' ) {
          
          return $params;
          
        }
        
        
        //add content to widget
        $content_type = get_field('content_type', 'widget_' . $widget_id);
    
        
        if( $content_type == 'important_links' ) {
          
           ?>
          <?php $params[0]['after_title'] .= '<ul>' ?> 
            <?php while(the_flexible_field("important_links", 'widget_' . $widget_id)): ?>
    
              <?php if(get_row_layout() == "file"): // layout: file 
                //vars
                $file_link_text = get_sub_field('file_link_text', 'widget_' . $widget_id);
                $file = get_sub_field('file', 'widget_' . $widget_id);
                $file_type = get_sub_field('file_type', 'widget_' . $widget_id);
    
              ?>            
    
                <?php $params[0]['after_title'] .= sprintf('<li><a href="%s" class="is-%s">%s</a></li>', $file['url'], $file_type, $file_link_text) ?>
    
              <?php elseif(get_row_layout() == "link"): // layout: link 
    
                $link_text = get_sub_field('link_text', 'widget_' . $widget_id); 
                $url = get_sub_field('url', 'widget_' . $widget_id); 
    
              ?>
                  <?php $params[0]['after_title'] .= sprintf('<li><a href="%s">%s</a></li>', $url, $link_text) ?>
                  
    
              <?php endif; ?>
    
            <?php endwhile; ?>
          <?php $params[0]['after_title'] .= '</ul>' ?> 
          
        <?php }
    
        if( $content_type == 'contacts' ) { ?>      
          
          <?php if( have_rows('contacts', 'widget_' . $widget_id) ): ?>
            <?php $params[0]['after_title'] .= '<ul>' ?>        
                
                <?php while( have_rows('contacts', 'widget_' . $widget_id) ): the_row(); 
    
                  // vars
                  $contact_name = get_sub_field('contact_name', 'widget_' . $widget_id);
                  $contact_title = get_sub_field('contact_title', 'widget_' . $widget_id);
                  $contact_phone = get_sub_field('contact_phone', 'widget_' . $widget_id);
                  $contact_email = get_sub_field('contact_email', 'widget_' . $widget_id);
                  $tel = preg_replace("/[^A-Za-z0-9]/", "", $contact_phone);
    
                ?>
                  
                  <?php $params[0]['after_title'] .= sprintf('<li><header><h4>%s</h4>', $contact_name) ?>
                  <?php $params[0]['after_title'] .= sprintf('<h5>%s</h5></header><p>', $contact_title) ?>              
                  <?php $params[0]['after_title'] .= sprintf('<a class="tel" href="tel:%s">%s</a><br />', $tel, $contact_phone) ?>
                  <?php $params[0]['after_title'] .= sprintf('<a class="email" href="mailto:%s">%s</a></p></li>', $contact_email, $contact_email) ?>              
    
                <?php endwhile; ?>
              
            <?php $params[0]['after_title'] .= '</ul>' ?>     
            
    
          <?php endif; 
          
          
          
        }
        // return
        return $params;
    
      }
    add_filter('dynamic_sidebar_params', 'my_dynamic_sidebar_params');
  • I too am having this issue.

    I have successfully created several custom fields and assigned them to multiple custom post types, but just today it stopped working with multiple post types.

    I have temporarily solved this issue by selecting ‘Post type’ ‘IS NOT equal to‘ ‘Page’ — but now these fields are on ALL custom post types, not just the necessary ones. This is an okay temporary fix, but would like to know what is happening else where.

  • Thanks addeo, I’ll try it.

    I just noticed it only happens with qtranslate fields! The rest of fields are working correctly. Is it the same for you?

  • // hide drafts
    function relationship_options_filter($options, $field, $the_post) {
    $options[‘post_status’] = array(‘publish’);
    return $options;
    }
    add_filter(‘acf/fields/post_object/query/name=<YOUR FIELD NAME>’, ‘relationship_options_filter’, 10, 3);

  • haha true! that did the trick.
    Stupid that I didn’t even try your code at first!

    Thanks anyway! p.s. I would really appreciate if you give your experienced view on my question here

    Thanks Jonathan!

  • Try adding the post_type or the meta_key

       	$args['meta_query'] = array(
       	    'post_type' => 'your_post_type',
       	     'meta_query' => array(
                   'key' => 'color',
                   'value' => 'blue',
                    'compare' => '!='
    	       )
        );
        return $args;
    
  • Hello,

    I have also the same question.
    For example: Show only 5 photos from the ACF Gallery on the Archive page.

    Anyone?

Viewing 25 results - 17,501 through 17,525 (of 21,345 total)