Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi Rociopts. thank you very much. I could solve it I leave the code for other people who can not find a solution.

    <div class="lista-taxonomia"> 
    <?php $types = get_terms( array( 'taxonomy' => 'nombre-de-la-taxonomia', 'hide_empty' => true, ) );
    foreach($types as $type) { ?>
    <div class="otra-div">
    <?php $image = get_field('nombre-del-campo-de-imagen', 'nombre-de-la-taxonomia_' . $type->term_id . '' ); 
    if ( has_term( $type->term_id, 'nombre-de-la-taxonomia')) {
    echo '<img class="imagenes" src="' . $image['url'] . '" /> ' . '<p>'. $type->name . '</p>'; 
    } ?> </div> <?php } ?>
    </div>
  • Hello, I’m yust saying that I can’t access to grid template (because of html array) as I can on product/single cruise template so I must access with jquery to add this field to grid template and I don’t know why doesn’t work…

  • A POST request with a good nonce, the action acf/validate_save_post and the fields data return valuable informations.

    {
    nonce: acf.o.nonce,
    action: 'acf/validate_save_post',
    acf[field_id1...]: 'value on the input field_id1...',
    acf[field_id2...]: 'value on the input field_id2...'
    }

    I’ve used it that way :

    $("#validation-button").click( function(e) {
       e.preventDefault();
       validateACFinputs($(this.form).serializeArray());
    });
    
    function validateACFinputs(form_data) {
       var data = {
          nonce: acf.o.nonce,
          action: "acf/validate_save_post",
          post_id: acf.o.post_id };
       for (const i in form_data) {
          data[form_data[i].name] = form_data[i].value;
       }
    
       $.post(
          my_ajax_obj.ajax_url, data,
          function(result) {
             errors = result.data.errors
             if (errors === 0) {
                // Code for success
             } else {
                // Code for fail
             }
          }
       );
    }

    (my_ajax_obj.ajax_url contains the url of admin-ajax.php, if you don’t know what it is, please read the WordPress documentation about admin-ajax.php)

    Notes :

    • A lazy/inefficient way to display acf errors is to do a .checkValidity() on one of the input, because it seems to cast the whole ACF validation process.
    • To verify required but empty fields you need to do it another way, I would suggest the use of checkValidity().
    • I may have seen a way to add errors with the Javascript object acf but I haven’t tried it yet.

    This remains incomplete compared to the classical behavior when you click on the submit…

  • We are having the same problem:

    TypeError: o is null

    Reuploading advanced-custom-fields-pro solved the error.

  • Hello,

    thanks but I create date and another custom field which works in product:
    http://wp.swlabs.co/exploore/cruises/alaska/

    and now I want show this field also in grid: http://wp.swlabs.co/exploore/cruises/

    Post type for cruises is only one in ACF: sizexploore_crusie.

    I add manualy to product template:

    
    <div class="class_field">
      <?php if( get_field('custom_field') ): ?>
        <h4>Somme text: <?php the_field('custom_filed'); ?></h4>
      <?php endif; ?>
     </div>
    

    But can’t add it on grid template, because of printf formated %1$s, %2$s, %3$s which don’t accept php because is html array, so I try to add this field to price with jQuery …

  • 'meta-query' should be 'meta_query'

    underscores and not dashes for argument names

  • Hello,

    thanks for answer,

    I try now:

    
    function pw_load_scripts() {
    
            wp_register_script('pw-script', get_template_directory_uri() . '/assets/public/js/custom_filed.js', array('jquery'));
    	wp_localize_script('pw-script', 'pw_php_vars', array(
    			'custom_filed' => custom_filed
    		)
    	);
            wp_enqueue_script('pw-script');
            
     
    }
    add_action('wp_enqueue_scripts', 'pw_load_scripts');
    
    

    and still getting text custom_field instead of value. Is maybe problem with jquery?

    I try with append and html

    Thanks for help,

    A

  • try change order of commands. This is my working example:

    function enqueue_scripts()
        $params = array ( 'someparam' => get_field('field_name', 'options') );
    
        wp_register_script('scripts', 'js/scripts.js', array('jquery'), false, false);
        wp_localize_script( 'scripts', 'params', $params );
        wp_enqueue_script('scripts');
    }
    add_action('wp_enqueue_scripts', 'enqueue_scripts');
  • This is my code now:

    $fastigheter = get_posts ([
    	'post_type' => 'fastigheter',
    	'numberposts' => -1,
    	'meta-query' => [
    		'relation' => 'OR',
    		[
    		        'key' => 'byggstatus',
    			'value' => 'Renoveras',
    			'compare' => '='
    		],
    		[
    			'key' => 'byggstatus',
    			'value' => 'Under Uppbyggnad',
    			'compare' => '='
    		]
    	]
    ]);

    I still get all the posts in the fastigheter cpt.

  • @elliot, I would be a major proponent of this. CF does this quite splendidly (I do a lot of multisite work), but (as a long-time ACF licensee) I’ve been thinking of switching back due to the impressive emphasis being put on PHP-friendliness, and especially, ACF Blocks (which is super exciting!!).

    There are so many great frameworks out there, all with pros and cons, but with all of the multisite work that I do, the Network Admin (sub-)menu options page is something I need. I could run two frameworks, but I prefer to reduce overhead when possible (or do it manually, but ACF and other frameworks are just nicer for such things).

    Cheers, great work and thank you all!
    Daniel

  • Just a note, this may not always work.

    
    var acf_field = acf.getField('field_56e1cf2e7ad26');
    acf_field.on("change ready", function(e){
    

    The reason being that it will not work on fields that are dynamically added after the page is loaded. In one of the sites I’m working on I needed to do something like this

    
    $(document).on('change', '[data-key="field_5b6c628cb8088"] .acf-input input', function(e) {
      // ...
    });
    
  • Location Rule: “Post Taxonomy” “is equal to” “SELECT THE TERM”

  • A select field, and by the looks of it can hold multiple values. See the section titled 3. Multiple custom field values (array based values) on this page https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

  • The validation works fine 🙂
    My problems appear because I have made a plugin settings page with ACF select boxes.
    If the box isn’t checked then the required php file will not be loaded

    In my plugin-name.php file I have

    
    if( $hc_custom_options && in_array('Event', $hc_custom_options) ) {
    require_once ('files/acf-event-fields.php');
    };
    

    The validation is on the files/acf-event-fields.php

    Unchecking the select box fires the error

    hope you understand my poor english … and my PHP skills 😉

  • I’ve ended up making a shortcode in which I could simply run a php wp query.

  • I’m not sure where or how you are updating. ACF needs to be updated using the plugin admin on the site. You’re probably getting a bad request error because you’re not including the activation key.

  • This usually happens when there is an error during the AJAX request. Check for PHP errors during the request.

    In your function you are using get_field() to get values. ACF has not saved any values during validation. When validating fields you need to look in the $_POST[‘acf’] array (or $_POST[‘fields’] if your using ACF4).

  • <?php 
    
    $image = get_field('image');
    
    if( !empty($image) ): ?>
    
    	<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    
    <?php endif; ?>
  • Appears to have been an issue with jQuery – got it enqueued properly and no more issue. 🙂

  • I think you should add the post/page where this “Screen” category will be shown.

    Something like this:

    
    Show this field group if
    [post type] [is equal to] [single product] (and)
    [post taxonomy] [is equal to] [screens]
    
  • I’m sorry I forgot to include the error when I click on one.

    Uncaught TypeError: a.ajax is not a function
        at Object.<anonymous> (wp-util.min.js?ver=4.9.8:1)
        at Function.Deferred (jquery-3.3.1.slim.min.js:2)
        at Function.send [as ajax] (wp-util.min.js?ver=4.9.8:1)
        at n.sync (media-models.min.js?ver=4.9.8:1)
        at n.fetch (backbone.min.js?ver=1.2.3:1)
        at n.more (media-models.min.js?ver=4.9.8:1)
        at n.more (media-models.min.js?ver=4.9.8:1)
        at n.prepare (media-views.min.js?ver=4.9.8:3)
        at n.render (wp-backbone.min.js?ver=4.9.8:1)
        at wp.Backbone.Subviews.<anonymous> (wp-backbone.min.js?ver=4.9.8:1)
  • ACF does not identify acf vs non-acf fields. For example, you can create an image field with the field name of “_thumbnail_id” and ACF will save the value to the standard WP featured image field and then this image can be used by all the WP functions that deal with the featured image. I do this for example to require a featured image for posts and then disable the WP featured image meta box.

    However, fields like title and content are different, these values are not stored in the postmeta table, they are stored in the post table and would not be effected.

    You can create fields in ACF using the same meta_key as used by some other plugin and ACF will store the values in the correct place for that plugin.

    The problem with this would be when two fields with the same name appear in the same forme. So, for example, if you were in the admin on the editor page for the events plugin and one of it’s fields was named “events_xyz” and you gave an acf field the same name and it appeared on the same admin page you will run into issues since both fields will be trying to save their values to the same place. Another issue may be that the other plugin might save the value in a different format than ACF stores the value. Another possible issue is that the other plugin does not actually store the values in the postmeta table, many plugins use custom db table. These are the reasons that I would go in the direction I mentioned, it chooses the safest path to prevent potential issues.

    Can you use this method and get away with using the same field names for ACF as used in the other plugin? I cannot answer this question.

  • Thanks for responding, John! That does sound like an option that could work.

    Maybe this is more of a general question about acf_form, but I assume that acf_form only allows you to write to

    1) custom fields created in ACF, and
    2) generic WordPress fields (title, content, etc.)

    Is that accurate?

    If so, how does acf_form identify the non-ACF fields? If I had the meta_key of a non-ACF custom field, could I write to it?

  • Thank your very much for your answer.

    “The only thing that I dislike about this is that there is nothing in the theme description that says “Oh, by the way, you’re going to have to buy licenses for these 6 plugins and that’s going to cost you more than you’re paying for this theme, and your going to have to pay that every year.”

    All plugins included in the themes are either free or paid but included with a lifetime license. I’ve never seen a theme on sale (at least on ThemeForest) that required you to pay an additional plugin to make the theme work properly.

    Also, I don’t understand this :

    “On the other hand, if you don’t plan on supplying updates to the people that buy your themes then you really don’t need to supply a license for ACF since the ACF license is strictly for updates.”

    This means that by buying a developer license, I can include the plugin in the theme, but the customer won’t be able to update the plugin, right?

  • Disclaimer, I am not part of ACF, I just help out here on this forum, so my opinions may not be those of the ACF developer.

    The way that it should work is that you have the license and you update the theme and then provide updates to the people that buy your theme.

    I don’t know how others are doing it. I don’t sell themes because in the US this requires sales tax and the sales tax system in the US sucks. I make my money by doing consulting/custom coding, which is not taxable.

    This is a personal opinion, but I would never include a plugin bundled in a theme. This is where I may disagree with ACF. I feel that bundling plugins in themes is overall a bad idea. The themes that we have purchased for clients that include plugins usually install those plugins and then we need to register them separately. The only thing that I dislike about this is that there is nothing in the theme description that says “Oh, by the way, you’re going to have to buy licenses for these 6 plugins and that’s going to cost you more than you’re paying for this theme, and your going to have to pay that every year.” At least with ACF it’s a one time cost and that cost in minimal.

    On the other hand, if you don’t plan on supplying updates to the people that buy your themes then you really don’t need to supply a license for ACF since the ACF license is strictly for updates. If you don’t plan on updating the theme then updating ACF is probably a bad idea anyway. ACF does occasionally release updates that can break existing code, not often, but it has been know to happen. I still have several sites that I have to fix before I can update them to 5.7.X because of the new JS API.

Viewing 25 results - 9,351 through 9,375 (of 21,340 total)