Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hello Chris, I try to use acf_reset_validation_errors() inside acf/validate_save_post.

    I can see the request to admin-ajax.php and it returns {"success":true,"data":{"valid":1,"errors":0}} but the error messages still appear and the post isn’t saved.

    I have set post_status to draft and I have this :

    add_action('acf/validate_save_post', 'clear_all_errors', 10, 0);
    function clear_all_errors() {
       acf_reset_validation_errors();
    }

    Can you share some code about how you did it ?

    EDIT : It was because now ACF use the required on inputs

    I’ve added formnovalidate on my submit button and it solved my issue.

  • So yesterday, I added the max_input_vars to my .htaccess file. No change. I then contacted my host about adding it to my php.ini file. Which is only accessible via SSH. Something I don’t work in. After much hand holding from my host’s tech support, I was able, through Mac Terminal to get into the php.ini file and change the commented out max_input_vars to uncommented and changed the 1000 to 5000. After all that, the plugin still says the max vars is 1000 and my ACF repeater will not save. Not sure what else to do. Not sure if rebuilding my ACF form in a different way would make a difference. For instance, I could make the parent repeater, not a repeater and instead make each of those individual repeaters. So that their is no nesting. But they are still all on the same page. It might make fewer vars but I think I would still hit 1000 pretty quickly.

  • Ok figured out the problem. In case anyone is dealing with similar issues:

    		if ( isset( $query->query_vars['post_type'] ) && ( 'post' === $query->query_vars['post_type'] || is_single() ) ) {
    			$query->set( 'orderby', 'meta_value' );
    			$query->set( 'meta_key', 'event_start' );
    			$query->set( 'order', 'ASC' );
    			$query->set( 'paged', get_query_var( 'paged' ) );
    			$query->set( 'posts_per_page', get_option( 'posts_per_page' ) );
    			$query->set( 'meta_query', array(
    				'relation' => 'AND',
    				array(
    					'key'     => 'event_start',
    					'compare' => '>=',
    					'value'   => date( 'Y-m-d H:i:s', strtotime( '-8 hours' ) ),
    					'type'    => 'DATETIME',
    				),
    			) );
    		}
    		return $query;

    Only paged and pages_per_page had to be added. Now it is working proplery.

  • I know, I’m late to this post. Still, here’s a quick and easy solution:

    
    $('.acf-form').on('click', '[data-event="remove-row"]', function(e) {
       $(this).click();
    });
    

    …mimics the double click 🙂

  • Just for the record I have updated to V5.7.1 of ACF. Bought the developer license to see if that fixed it.

    No joy still only shows fields under PHP V5.3

    It’s something to do with this code for certain

    
    if(get_field('name'))
    $field_name = "name";
    if(empty($field_name['name'])){
    
        echo " ";}
    
    else
    ....
  • You cannot order by a repeater sub field. Ordering by any meta field requires that all of the values are stored with the same meta key and this is not how a repeater works. My suggestion is to read this https://acfextras.com/dont-query-repeaters/

  • I have had a look into this and it seems I am using an if statement that has since been changed since PHP V5.3.

    I other words in PHP V5.3 this code shows all the ACF field data

    if(get_field('name'))
    $field_name = "name";
    if(empty($field_name['name'])){
    
        echo " ";}
    
    else
    ....

    However if you upgrade from 5.3 upward this statement stops the PHP fields showing … take the ‘if’ statement out it all shows again.

    So it seems I need to upgrade this ‘if’ statement somehow

  • The only possibility that I know of is max_input_vars, but it could be suhosin.post.max_vars or suhosin.request.max_vars also needs to be set. Try this plugin https://wordpress.org/plugins/wp-max-submit-protect/

  • So I did end up just creating the vCard upon saving the custom post type by cobbling together a few different methods. I started with this function:

    function hj_create_vCard( $post_id ) {
    
    	/*
         * In production code, $slug should be set only once in the plugin,
         * preferably as a class property, rather than in each function that needs it.
         */
        $post_type = get_post_type($post_id);
    
        // only update the attorneys custom post type on save
        if ( "attorneys" != $post_type ) return;
    
        $vpost = get_post($post->ID);
        $filename = $vpost->post_name.".vcf";
        header('Content-type: text/x-vcard; charset=utf-8');
        header("Content-Disposition: attachment; filename=".$filename);
        $data=null;
        $data.="BEGIN:VCARD\n";
        $data.="VERSION:3.0\n";
        $data.="FN:".$vpost->post_title."\n"; // get post title
        $data.="ORG:Client Company Name\n";
        $data.="EMAIL;TYPE=work:" .get_field('att_email',$vpost->ID)."\n";  // get acf field value
        $data.="TEL;WORK;VOICE:" .get_field('att_phone',$vpost->ID)."\n";  // get acf field value
        $data.="ADR;WORK;PREF:123 Fake Street;Fake City;MN;55106\n";  // get acf field value
        $data.="END:VCARD";
        $filePath = get_template_directory()."/vcard/".$filename; // you can specify path here where you want to store file.
        $file = fopen($filePath,"w");
        fwrite($file,$data);
        fclose($file);
    }
    add_action( 'save_post', 'hj_create_vCard' );

    Then for use in my template I just grab the file that is generated on save by looking for the file based on its name, which is generated from the page slug:

    <?php
    global $post;
    $vcfname = $post->post_name;
    ?>
    
    <a href="<?php echo get_template_directory_uri(); ?>/vcard/<?php echo $vcfname; ?>.vcf"><i class="far fa-address-card"></i> Download Vcard</a>
  • Hi,

    I run WP 4.9.7 with ACP Pro (Developer Licence) 5.7.1.

    I have exactly the same problem: I cannot save a page!

    The only way I found to edit a page is:
    1. Pass the page from Public state to Draft, with the quick editing function.
    2. Modify the page and save as a draft.
    3. Pass the page from Draft state to Public, with the quick editing function.

    When I unactivate ACF Pro 5.7.1 in extension list, this bug is away. So I would like to know where can I donwload the latest previous 5.6.x package of ACF Pro, to fix my website as soon as possible.

    Thank you a lot.

  • posted this on another thread but might also be what you’re looking for

    function get_acf_fields_post_type( $post_type )
      {
          global $wpdb;
    
          $sql = "SELECT p.ID, p.post_title, p.post_name, pm.meta_value as rule
                  FROM $wpdb->posts p 
                  LEFT JOIN $wpdb->postmeta pm 
                  ON ( p.ID = pm.post_id AND pm.meta_key = 'rule' ) 
                  WHERE p.post_type = 'acf'";
    
          $result = $wpdb->get_results($sql);
    
          $groups = array();
    
          foreach($result as $row){
    
            $rule = unserialize($row->rule);
    
            if( $rule['param'] == 'post_type' && $rule['operator'] == '==' && $rule['value'] == $post_type )
            { 
              $groups[$row->ID] = array('title'=>$row->post_title,'name'=>$row->post_name);
            }
    
          }
    
          foreach($groups as $post_id => $data)
          {   
              $fsql = "SELECT * FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key LIKE 'field_%';";
    
              $fields = $wpdb->get_results($fsql);
    
              $field_array = array();
              foreach($fields as $field)
              {
                $f = unserialize($field->meta_value);
                $field_array[$field->meta_key] = $f; 
              }
              $groups[$post_id]['fields'] = $field_array;
          }
    
          return $groups;
    
      }
  • This seems relatively tricky.

    One way would be to use the Caption or Description meta box in the Image Uploader to store a class name, and then output it like this

    <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" class="<?php echo $image['caption']; ?>"/>

    Or you could output a generic class for all images

    <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" class="gallery_images_class"/>

    and then use a css :nth-of-type selector to target specific instances (eg. images 4, 7 out of 10)

  • Hi John

    Thank you for the comprehensive reply. I do feel having read @giovannicold‘s reply again they are on the right lines. I have tried the solution you offered and the span class value are also stored in the database which is something I don’t want as these also get passed to my filter system which looks shocking.

    If I could figure out how and where to apply @giovannicold‘s fix then I would give it a shot but I can’t seem to get it to work in my theme.

    I’ll do some more reading up I think, thank you once again for your reply. Maybe this one requires someone a little more experienced than me to tackle. Thanks again.

  • If you are still ordering by a single meta field you can still to that without a lot of work. I think this will work.

    
    $byartist_args = (array(
     'numberposts' => -1,
     'post_type' => 'Event',
     'meta_query' => array(
      'relation' => 'AND',
      array(
       'key' => 'artist',
       'value' => get_the_ID(),
       'compare' => '=',
      ),
      array(
       'key' => 'event_date',
       'compare' => 'BETWEEN',
       'type' => 'DATE',
       'value' => array($date_1, $date_2),
      ),
     ),
     'meta_key' => 'event_date'
     'orderby' => 'meta_value_num',
     'order' => 'ASC',
     'nopaging' => true
    ));
    
  • I did mean to add that adding custom html and css to a field’s label is possible when editing the choices in acf. This will work as value/label pairs and include your html in the label

    
    red : <span class="red">Red</span>
    green : <span class="green">Green</span>
    blue : <span class="blue">Blue</span>
    
  • A checkbox field stores an array of selected values. You need to get the current value of the field, add the value you want to the array and then update the field.

    But please see my previous comment, your original code was missing a loop for each of the posts you returned with your query.

    
    $args = array(
                'post_type' => 'namaste_course',
                'post_status' => 'publish',
                'posts_per_page' => -1,
                );
    
                $post_query = new WP_Query( $args );
                if ($post_query->have_posts()) {
                  global $post;
                  $field_key = "field_59654068371a3";
                  while ($post_query->have_posts()) {
                    $post_query->the_post();
                    $value = get_field($field_key, $post->ID, false);
                    $value[] = 'CEUAP';
                    update_field( $field_key, $value, $post->ID );
                  }
                  wp_reset_postdata();
                }
    
  • I’m still learning here and just realised that the field_key is for the entire field and not the particular checkbox.

    <div class="acf-field acf-field-checkbox acf-field-59654068371a3" data-name="certifications" data-type="checkbox" data-key="field_59654068371a3">
    		<div class="acf-label"><label for="acf-field_59654068371a3">Certifications</label></div>
    		<div class="acf-input">
    		<input name="acf[field_59654068371a3]" type="hidden">
    <ul class="acf-checkbox-list acf-bl">
    <li><label><input id="acf-field_59654068371a3-NASM" type="checkbox" name="acf[field_59654068371a3][]" value="NASM">NASM</label></li>
    <li><label><input id="acf-field_59654068371a3-ACSM" type="checkbox" name="acf[field_59654068371a3][]" value="ACSM">ACSM</label></li>
    <li><label><input id="acf-field_59654068371a3-NATA-BOC" type="checkbox" name="acf[field_59654068371a3][]" value="NATA-BOC">NATA-BOC</label></li>
    <li><label><input id="acf-field_59654068371a3-ProCert" type="checkbox" name="acf[field_59654068371a3][]" value="ProCert">ProCert</label></li>
    <li><label><input id="acf-field_59654068371a3-AFAA" type="checkbox" name="acf[field_59654068371a3][]" value="AFAA">AFAA</label></li>
    <li><label><input id="acf-field_59654068371a3-NCBTMB" type="checkbox" name="acf[field_59654068371a3][]" value="NCBTMB">NCBTMB</label></li>
    <li><label><input id="acf-field_59654068371a3-CanFitPro" type="checkbox" name="acf[field_59654068371a3][]" value="CanFitPro">CanFitPro</label></li>
    <li><label><input id="acf-field_59654068371a3-PTAGlobal" type="checkbox" name="acf[field_59654068371a3][]" value="PTAGlobal">PTAGlobal</label></li>
    <li><label><input id="acf-field_59654068371a3-CEUAP" type="checkbox" name="acf[field_59654068371a3][]" value="CEUAP">CEUAP</label></li>
    </ul>
    					</div>
    </div>

    I’d like to check the latter one, but using key acf-field_59654068371a3-CEUAP does not work. Any advice? Also, thanks for your reply.

  • John, this is great, thank you (as always). It worked exactly as you suggested.

    I am now trying, however, to make sure I can still present them in date order (the other meta query). I’ve been using this to do that in other feeds:

    'orderby' => 'meta_value_num',
    'order' => 'ASC',
    'nopaging' => true

    Of course, now there are two meta queries, there are two meta values too, so how can I specify which is to be used for ordering? At the moment it seems a bit confused.

    Here’s the whole thing as it stands currently:

    $byartist_args = (array(
     'numberposts' => -1,
     'post_type' => 'Event',
     'meta_query' => array(
      'relation' => 'AND',
      array(
       'key' => 'artist',
       'value' => get_the_ID(),
       'compare' => '=',
      ),
      array(
       'key' => 'event_date',
       'compare' => 'BETWEEN',
       'type' => 'DATE',
       'value' => array($date_1, $date_2),
      ),
     ),
     'orderby' => 'meta_value_num',
     'order' => 'ASC',
     'nopaging' => true
    ));

    Thank you!

  • 
    $args = array(
                'post_type' => 'namaste_course',
                'post_status' => 'publish',
                'posts_per_page' => -1,
                );
    
                $post_query = new WP_Query( $args );
                if ($post_query->have_posts()) {
                  global $post;
                  $field_key = "field_59654068371a3";
                  $value = true;
                  while ($post_query->have_posts()) {
                    $post_query->the_post();
                    update_field( $field_key, $value, $post->ID );
                  }
                  wp_reset_postdata();
                }
    
  • The query you are running would show only the posts assigned to this artist if done correctly. If you’re post object field only allows a single value then that value is not stored as a serialized array. What are the settings of the post object field “artist”? Does it allow multiple values? If it does then your meta query should be correct, if it only allows one value then your query should be

    
    array(
       'key' => 'artist',
       'value' => get_the_ID(),
       'compare' => '=',
      ),
    
  • Hi, i’m trying another way.. but obviously it doesn’t work..
    thank’s a lot to anyone can help me :
    A “second” dropwdown called “456” must have the value selected on the first called “123” ..
    PHP

    function my_acf_input_admin_footer() {
    	
    ?>
    <script type="text/javascript">
    (function($) {
    	
    	var x = document.getElementById("acf-field_123"); //first dropdown field
    
    	if (x.addEventListener) {                    // For all major browsers, except IE 8 and earlier
        	x.addEventListener("change", myFunction);
    	} else if (x.attachEvent) {                  // For IE 8 and earlier versions
        	x.attachEvent("onchange", myFunction);
    	}	
    	function myFunction(){
    		var x = document.getElementById("acf-field_123");
    		var y = document.getElementById("acf-field_456"); //second dropdown
    		x.value=y.value;
    	}
    	
    })(jQuery);	
    </script>
    <?php
    		
    }
    
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');
  • Nice plugin, good job @happiness 🙂

    Anyway we can use filters like this example:

    add_filter('wp_nav_menu_items', 'my_wp_nav_menu_items', 10, 2);
    
    function my_wp_nav_menu_items( $items, $args ) {
        $menu = wp_get_nav_menu_object($args->menu);
        $menuSlug = $menu->slug;
        if ($menuSlug == 'hamburger-menu') {
            if (is_user_logged_in()) {
                $items .= '<li id="menu-item-logout" class="menu-item menu-item-logout"><a href="'. wp_logout_url(home_url()) .'">LOGOUT</a></li>';
            } else {
                $items .= '<li id="menu-item-login" class="menu-item menu-item-login"><a href="'. home_url() .'/logowanie">LOG IN</a></li>';
            }
        }
        return $items;
    }

    This is an answer for related question “How to add items to an ACF Nav Menu?”
    Hope it helps for future questions about it.

  • Sorry for the late reply – this worked perfectly, many thanks for your quick help!

Viewing 25 results - 9,401 through 9,425 (of 21,340 total)