Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hello,

    I solved the issue, it was actually my mistake: there was another query before the custom fields that needed to be reset.
    I posted the working snippet here: http://wordpress.stackexchange.com/questions/188440/acf-pro-repeater-field-returns-null

  • Still having this issue with 5.2.6, and I’ve identified that it seems to be having issues with the YARPP plugin.

    Specifically it breaks when I try to step through a flexible content field in the featured posts being pulled.

    If I call this line:

    if( have_rows('page_content') ):

    OR

    while(has_sub_field("page_content")):

    All my acf fields just don’t work on the page at all. There are no errors displayed (debug off, etc)

    To confirm, reverting to 5.2.3 fixes this issue.

    —-

    EDIT 2:

    Alright now I’ve discovered if I add a meta description in YOAST SEO it also seems to fix the issue, but with the meta description field blank it creates the issue as well. It also fixes it if I disable to Yoast plugin completely.

    I’m getting pretty confused as to what is causing this? Something being called or not called that’s triggered by various things perhaps?

    To clarify, it’s fixed by any of the following:

    – Removing the flexible content field call from the related posts plugin / disabling this plugin
    – Having a filled in meta description field in YOAST SEO or disabling the YOAST SEO plugin
    – Rolling back ACF PRO to 5.2.3

  • I’ve not had experience with that plugin or using it, so to be honest I’m not sure where I’d start. Probably would have tried to figure out it it let me get an the data for an attachment and then done what us suggest, navigate the array in JavaScript to find the id and make another request.

    I’m glad to know you found a solution.

  • I can’t say if you will definitely run into the same problem. I can say that I have some pretty big sites that I maintain that use ACF extensively and some of the things I’ve created have hundreds of custom fields that ACF manages. This usually requires me to bump up the maximum memory limit for the site. (php ini setting memory_limit)

    I can tell you that for each field that that is saved for a post that ACF creates 2 rows in the postmeta table. One for the value of the field itself and one that tells ACF how to treat that value. So it you have a field group with 100 fields then at a minimum ACF will create 200 rows. Some special fields like repeaters will create 1 row for the repeater itself and 2 rows for each field in the repeater.

  • It looks like you have everything you need except a `pre_get_posts’ filter.

    I recently did this on a site I was working on. Basically, you need to add a filter.

    Here is the filter that I used:

    
        function reference_pre_get_posts($query) {
          // only in admin
          if (!is_admin() || !$query->is_main_query()) {
            return;
          }
          if ($query->query_vars['post_type'] == 'reference' && 
              ($orderby = $query->get('orderby'))) {
            switch ($orderby) {
              case 'featured':
              case 'reference_featured':
                $query->set('meta_key', 'reference_featured');
                $query->set('orderby', 'meta_value_num');
                break;
              default:
                // do nothing
                break;
            }
          } // end if reference and orderby
        }
    

    basically it test to see if we’re in the admin and if we are querying my post type and it it is one of the meta_keys I’ve set up as a sortable field. If it is then I add the meta_key that it needs to be ordered by and change the orderby to meta_value.

    Hope this helps

  • WordPress has a habit of remembering the order that meta boxes are displayed and showing them in that order the next time the page is loaded. This can override the values that you set for the display order you set in the order no value of the field group. WP saves the order that you last saw the field when a post is saved and this also happens during a WP autosave.

    This value is stored in the database in the usermeta table with the meta_key of met-box-order_{$post_type}

    Once this value is saved by WP the only way you can change the order of the meta boxes is to drag them to a different position while looking at the edit post page. You can also delete this value from the database and that will reset the display order of the meta boxes to their original configuration. This is so that each person can reorder the boxes to their own preferences. WP does not have a way to reset this without manually deleting the values from the DB.

    Check out this post on Stack Exchange: http://wordpress.stackexchange.com/questions/38646/reset-positions-of-metaboxes-in-admin

  • Yes there is. ACF stores fields on user forms in the usermeta table.

    The difficulty is that checkbox fields are arrays stored as serialized data. In order to do a user query you would need to use the “LIKE” compare method in the meta_query for the user query.

    something like

    
    'meta_query' => array(
      array(
        'key' => 'my_field',
        'value' => 'my_value',
        'compare' => 'LIKE'
      )
    )
    

    if you’re looking for more than one value then you’d need to look for each value with and ‘AND’ or ‘OR’ for the relation value, depending on what you want returned.

    https://codex.wordpress.org/Class_Reference/WP_User_Query

  • If I get what you’re trying to do correctly, I think that you’ll need to have the user field both the options page and the user page.

    Set the user select field on the options page to return ID. This will return an array of user ID values.

    Then change your meta query to

    
        'meta_query' => array(
            array(
                'key' => '',
                'value' => $ids,
                'compare' => 'IN'
            ),
        ),
    
  • ACF stores checkbox fields hold an array and these are stored in the database as serialized data so testing the value being = to one of your checkbox values will not work.

    Something like this might work:

    
    $args = array(
        'post_type' => 'oil-products',
        'orderby' => 'title',
        'order' => 'ASC',
        'post_per_page' => 40,
        'meta_query' => array(
            array(
                'key' => 'type',
                'value' => 'Household'
                'compare' => 'LIKE'
            )
        ),
    );
    $loop = new WP_Query($args);
    
  • Hi @elliot

    EDIT: Okay, I was able to fix it not going to /publish/ but now it’s not adding the query args still. Thanks.

    Thanks for responding to this after almost 2 years. I was in the middle of creating a new service when ACF 5 came out, so I didn’t have issues with implementing it. However, I’m now updating my other site for ACF5 and I’ve ran into this issue with the redirect.

    I’ve tried a few things and I can’t seem to get it to redirect to a) the declared page (in my case, a /publish/ page… I am saving submission as draft and the publish page is for a payment gateway.) and b) with the query args needed to supply the logic to the publish page.

    Any thoughts on this? I’m happy to share my source code. Your plugin has made two pretty large sites successful.

    $args = array(
    							'post_id' => 'new_post',
    							'new_post' => array(
    						        'post_status' => 'draft',
    						        'post_type'  => $cpt,
    						        //'post_title' => 'new listing'
    							),
    							'html_before_fields' => $htmlbefore,
    							'field_groups' => $fieldgroups,
    							'form_attributes' => array('class' => $formattr,'autocomplete' => 'false'),
    							'return' => home_url('publish/'),
    							'submit_value' => 'Submit Listing'
    						);
    
    						acf_form( $args );

    That’s the form.

    And here is one of the pre_save_post functions:

    function my_pre_save_post( $post_id )
    	{
    	    // check if this is to be a new post
    	    if( $post_id != 'new' ) {
    	        return $post_id;
    	    }
    
    	    // Get Post Type
    	    $listing_type = $_POST['acf_form']['bh_post_type'];
    	    $perftype = $_POST['acf_form']['bh_perf_org_type'];
    	 
    	   // Create a new post
    	    $post = array(
    	        'post_status' => 'draft',
    	        'post_type'  => $listing_type,
    	        'post_title' => 'new listing'
    	    );  
    	 
    	   // insert the post
    	    $post_id = wp_insert_post( $post );
    
    	    if ($perftype) {
    	    	update_post_meta( $post_id, 'bh_perf_org_type', $perftype );
    	    }
    
            $query_args = array(
                'pid' => $post_id,
                'step' => 'pick',
                'ptype' => $listing_type,
                'msg' => 'success'
            );
    
            
    
    	    // update $_POST['return']
        	 $_POST['acf_form']['return'] = add_query_arg( $query_args,  $_POST['acf_form']['return'] );
    	 
    	    // return the new ID
    	    return $post_id;
    	}
     
    add_filter('acf/pre_save_post' , 'my_pre_save_post', 10, 1 );

    I know you said $GLOBALS above there and I tried that, but no go, so I went back to $_POST. I didn’t run into this with my other site but it’s also set to return to the same page with just some queries (post is added through a modal).

    Thanks in advance if you notice anything!

    Chris

  • Hey,

    Yes, unless I’m misunderstanding what you’re attempting to do. Here is a screen shot of creating a relationship field and selecting Tag.

    https://drive.google.com/file/d/0B7ljozO6CDk4eVlqZjYwWHNyMG8/view?usp=sharing

    Please let me know if I’ve got this wrong.

  • Are you still looking for help with this? if yes, a couple of questions.

    Is the customer field on the testimonial a Relationship field or a Post Object? Since I’m assuming that there can only be a single customer related to a testimonial it makes more sense to me that it would be a Post Object field which would return a single post object instead of an array.

    If this is not the case can you do a dump of $testimonialCustomer right after you get the field? Something like this would work`
    echo ‘

    '; print_r($testimonialCustomer); echo '

    ‘;

    then post the results.

  • update: I think I almost figured out how to do this…

    in advanced custom fields under “field_name” I put something which I thought would be unique because I’m guessing this is the meta key? So I put in a text field called “link_post”. Then in my front end publishing ap, I’m able to add fields by adding the meta key – I put in link_post and it seems to have worked. On the front-end form, I put in a link and then it showed up in the backend!!

    HOWEVER on the blog posting only the regular content showed. This additional field I made with advanced custom fields did not show in the blog article. Also… how would I organized and “call” all links with a certain tag to appear on a certain page?

  • When you say,

    .. that does a simple loop through the ACF Gallery data structure and renders out a thumbnail gallery.

    makes me think you’re doing something outside of what a standard WP loop would do, so also outside any type of standard pagination that could be used, so it’s going to need to be custom built.

    As an alternate, and this is just a suggestion to think about, Don’t know how far you are into this thing, and it might be too far along to change plans, but, I would use a custom post type with an archive, use pre_get_posts to set up how many to show, and then use standard WP pagination and let WP take care of the details.

  • Hi,
    We had a small bug with qtranslate earlier on.
    Kindly update to the latest version of acf and let me know if the problem still exist.

  • This works for me

    add_action('acf/save_post', 'custom_acf_save_post', 20);
    function custom_acf_save_post( $post_id ) {
    	
    	// bail early if no ACF data
    	if( empty($_POST['acf']) ) {
    		
    		return;
    	}
    
    	$data['ID'] = $post_id;
    	// Combine first name and last name to create a title
    	$title = trim($_POST['acf']['field_55687a737d49f']) . " " . trim($_POST['acf']['field_55687a917d4a0']);
    	$data['post_title'] = $title;
    	$data['post_name'] = sanitize_title( $title );
    
    	wp_update_post( $data );
    
    }
  • This reply has been marked as private.
  • I am not sure about the reason why such a thing would happen but its quite certain that the code may not have been the reason for the deleted field.

    In such instances you may consider checking if the field exists in the database or has been deleted.

  • Hi,
    The true/false field is quite easy and straightforward to use.
    Check out the following article in the documentation on how to do use the field

    How to use the true/false field

  • This reply has been marked as private.
  • This reply has been marked as private.
  • This is normal. The conditional logic only hides the fields and makes them not required if the field has been set to required. On the front end you need to test the field that sets the yes or no and then only show the values if it is set to yes.

  • Not really an ACF question, but yes.

    See the codes for switch_to_blog: http://codex.wordpress.org/Function_Reference/switch_to_blog

    Once you have switched the blog then all operations work as if that blog is the current blog.

  • This reply has been marked as private.
  • Hi @kitt

    Thanks for the feature request.

    I can add in a setting to allow a confirmation popup. Leave it with me and I’ll have a think about the best way to add this in

Viewing 25 results - 16,826 through 16,850 (of 21,394 total)