Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • hy,

    thank you for your quick reply! i cleared browser cache one more and accessed the site via a fresh browser as well, but that does not make any changes :/

    i am not sure if it may have something to do with woocommerce installed and enabled in this site. because i find this line:
    <link rel='stylesheet' id='select2-css' href='https://www.rinnhofer.info/wp2018/wp-content/plugins/advanced-custom-fields-pro/assets/inc/select2/4/select2.min.css?falkeTS=61277bd691e4f2021' media='all' />
    which seems fine.

    but i can not find a line with select2-js pointing to a js-file inside acf.

    but i can find a line:
    <script src='https://www.rinnhofer.info/wp2018/wp-content/plugins/woocommerce/assets/js/select2/select2.full.min.js?falkeTS=61277bd691e4f2021' id='select2-js'></script> which may be have the same file-handle and use a different version inside woocommerce?

    matt

  • Hey @twansparant!

    This was a fun one to look into!

    Turns out, React’s behaviour for tags like that will be false, so because you’re using JSX parsing for the block, it’s reading it as “false” and not showing it at all.

    If you set them all to “playsinline=’true'” they will work correctly, apart from “muted”, which never appears in the DOM – but this appears to be a known issue with React, and the while the video will actually be muted, it won’t appear in the DOM: https://stackoverflow.com/questions/61510160/why-muted-attribute-on-video-tag-is-ignored-in-react

    Hope this helps!

  • What does $recent["news_source"] return? I don’t think it returns anything useful because there is no “news_source” item in the post array. Try it with get_field('news_source') or possibly get_field('news_source',$recent['ID']).

  • I constantly have this problem after I migrate websites. Sometimes simply deactivating the license and activating works but many times it doesn’t. I have been in contact with support and they offer a few suggestions which sometimes work but again often don’t(see below from support).

    There is obviously a problem with how the license key is registered it would be great if ACF could address this.

    ================
    From ACF Support
    ================

    When ACF loads the license key information saved into the wp_options table, it validates the data saved against the current URL. If the website’s URL is different to the URL that was saved, ACF will not load or display that license key.

    Therefore, migrating a site invalidates the current activation since the website’s URL will be different to the URL that was saved.

    When this “issue” occurs, all that is needed is to enter a valid license key into the “Custom Fields > Updates” page. This will ping our server and register that URL with our API and thus allow package downloads for your website.

    When experiencing “Update package not available” issues, 99% of the time the problem is due to something wrong in the download URL. Which is fixable by deactivating and then re-activating the ACF PRO ‘license’ activation from the “Custom Fields > Updates” page.

    Are you able to see this activation in the list of activations on your online dashboard?
    Would you please confirm if the plugin is correctly activated and the website URL visible from your online account dashboard by logging in to your ACF Dashboard, then navigate to the Licenses tab and click on the “Manage Activations” button?

  • You are a genius, thank you..

    for anyone new looking, you are missing a couple of quotes, but it works great.. revised

    
    add_action('acf/save_post', 'force_revisions_save', 1);
    function force_revisions_save($post_id) {
      if (is_admin()) {
        // not needed in admin
        return;
      }
      $post_type = get_post_type($post_id);
      if ($post_type != 'YOUR POST TYPE HERE') {
        // only run on your post type
        return;
      }
      // get the post
      $post = get_post($post_id);
      // remove this filter to prevent infinite loop
      remove_filter('acf/save_post', 'force_revisions_save', 1);
      // update the post
      wp_update_post($post);
      // re-add this filter
      add_action('acf/save_post', 'force_revisions_save', 1);
    }
  • for example on the end of wp-settings.php I add:

    class XmlRpcAcf {
        public function __construct(){
            add_action('save_post', array( $this,'my_save_post'), 12, 3);
        }
        public function my_save_post( $post_ID, $post, $update ){
            //error_log("XmlRpcAcf.save_post($update)[$post_ID]:".json_encode($post), 0);
            if (!array_key_exists('_acf_nonce', $_POST)) {
                foreach ( (array) has_meta( $post_ID ) as $meta ) {
                    if (substr($meta["meta_key"], 0, 1) == '_') {
                        continue;
                    }
                    update_field( $meta["meta_key"], $meta["meta_value"], $post_ID );
                    //error_log("XmlRpcAcf.save_post.meta:".json_encode($meta), 0);
                }
            }
        }
    }
    $myMXmlRpcAcf = new XmlRpcAcf();
  • I just developed this feature for my company, this is the solution (MIT license, as is)

    Create this class within a file in your project, f.i. PageSlug_Location.php

    
    if( ! defined( 'ABSPATH' ) ) exit;
    
    class PageSlug_Location extends \ACF_Location {
    
    	public function initialize() {
            $this->name = 'page_slug';
            $this->category = 'page';
    		$this->label = __( 'Page by slug' );
        }
        
    	public function match( $rule, $screen, $field_group ) {
            
            if ( empty( $screen['post_type'] ) || $screen['post_type'] !== "page" ) {
                return false;
            }
    
            $page = get_post( $screen['post_id'] );
            
            return $rule['operator'] == "==" xor $rule['value'] !== $page->post_name;
        }
        
        public function get_values( $rule ) {
            $choices = array();
        
            $posts = get_posts( array(
                "post_type" => "page",
                "post_status" => "publish",
                "posts_per_page" => -1
            ));
    
            foreach( $posts as $post ) {
                $choices[ $post->post_name ] = $post->post_title;
            }
            
            return $choices;
        }
    }
    acf_register_location_type( PageSlug_Location::class );
    

    Then require the file at ACF init hook, put this in functions.php:

    
    add_action('acf/init', function() {
        require_once('PageSlug_Location.php');
    });
    

    I hope it should be helpful for someone.

  • When I do that I get a syntax error.

    This is what I wrote

    <?php $value = get_field('doors'); ?>
    <?php if ($value == 'YES') ?>
    <div class="feature">With doors</div>
    <?php endif; ?>
  • It worked John! Thanks a lot for all the help, I’ve been troubleshooting this for over a month already.

    BTW, can you add the function tag to that function, just in case someone wants to copy and paste the solution?

    Looking past what the cache is returning, I would look at what could be causing the get_posts() query to return an empty array, because this is where the empty array in the cache is being set. This has to happen at some point before you see the fields disappear.

    Regarding your previous comment, I’m not sure to what line or file are you referring, but the line that’s returning an empty array is not get_posts(), it’s this one:

    $post_ids = wp_cache_get( $cache_key, 'acf' );

  • I do not know if this will work, it is purely a guess based on what I know

    
    add_action('acf/init', 'check_acf_get_field_group_posts_cache', 20);
    check_acf_get_field_group_posts_cache() {
      $cache_key = acf_cache_key("acf_get_field_group_posts");
      $post_ids = wp_cache_get( $cache_key, 'acf' );
      if ($post_ids !== false && empty($post_ids)) {
        // not false which should be returned for an empty cache
        // but empty, indicating an empty array
        // delete the cached value
        wp_cache_delete(acf_cache_key("acf_get_field_group_posts"), 'acf');
      }
    }
    
  • Looking past what the cache is returning, I would look at what could be causing the get_posts() query to return an empty array, because this is where the empty array in the cache is being set. This has to happen at some point before you see the fields disappear.

  • Hey @proxxim ,

    in case you’re still wondering, I could easily just put it in a enqueued JS file that loads in the backend, and the colour picker only offers up theme colours which are defined for Gutenberg via theme.json. No need to wrap the code above, and you can easily enqueue the JS like normal (the CSS file is not needed though):

    function load_admin_stuff() {
    	wp_enqueue_style( 'admin_css', get_stylesheet_directory_uri() . '/css/admin.min.css', false, '' );
        wp_enqueue_script( 'admin', get_template_directory_uri() . '/js/admin.min.js', array(), '', true );
    };
    
    add_action( 'admin_enqueue_scripts', 'load_admin_stuff' );

    Can’t help you with the terms stuff, though I would suppose ACF just reads the values from Gutenberg, but doesn’t necessarily need Gutenberg to be loaded.

  • 
    'meta_query' => array(
      'relation' => 'OR',
      array(
        'key' => 'leave_this_article_out_of_similar_articles',
        'value' => '1',
        'compare' => '!='
      ),
      array(
        'key' => 'leave_this_article_out_of_similar_articles',
        'compare' => 'NOT EXISTS’'
      )
    ) 
    
  • It is possible to have filters and actions in the theme that effect the admin. Also any function. functions.php and any files that this file loads are loaded in the admin. But if you’ve tried other themes then this should be eliminated.

    I would say it could be a possible read issue if you are using local json, but since this requires having a folder in the theme folder, this should also be eliminated by changing themes.

    I honestly have not idea what could be causing your problem.

    At this point, if it were me, I would wait until it happens and then I would attempt to figure out why it’s not happening. I would do this by opening the main ACF file /plugins/advanced-custom-fields-pro/acf.php, and I would follow the code and find where the field group is and using echo, print_r and var_dump on variables in ACF I would see if I can figure out what’s going on.

  • This is how I got it to work, but it seems there should be an easier way?

    $event_query = new WP_Query(     
        array(
            'post_type' => 'al_event',
            'orderby' => 'menu_order',
            'order' => 'ASC',
            'meta_query' => array(
                array(
                    'key'     => 'event_date_end',
                    'compare' => '>=',
                    'value'   => $today,
                ),
                array(
                    'key'     => 'event_date',
                    'compare' => '<=',
                    'value'   => $future,
                ),
                array(
                    'relation' => 'OR',
                    array(
                        'key' => 'hide_on_public_page',
                        'value' => '0'
                    ),
                    array(
                        'key' => 'hide_on_public_page',
                        'compare' => 'NOT EXISTS', 
                    )
                )
            ),
        ) );
  • This is how I have the code in the functions.php file:

    $site_features = get_field('site_features');
    if( $site_features ): ?>
    <ul>
        <?php 
    // notice the missing "s"
    foreach( $site_features as $site_feature ): ?>
            <li><?php echo $site_feature; ?></li>
        <?php endforeach; ?>
    </ul>
    <?php endif; ?>
  • Sure. I understand. This is the way I have the field setup:

  • One idea i had, is to duplicate the ACF fields – the repeater three levels deep – and then delete all the fields except the one field that we are trying to update ( for roughly 400 listings). Maybe I could put that on an ACF options page, and link it to the other fields?

    That would be great if it worked, as they are launching by Friday, and this is the very last piece. It would still be problematic in the future when they want to update any of the fields on the page that won’t save. But if something like above worked, then down the road, other fields could be removed from that page and set on options page and linked in the same way.

    The other big hurdle is we spent so much time on this page – custom PHP, jQuery, CSS, HTML, (AND – all of it has a Hebrew version, most of which has to be manually duplicated then adjusted.) If we can somehow make it work without having to touch all the code for the most part, that would be amazing.

    I know you like to help and have helped me more than a few times, and I appreciate that – but I’d be happy to Venmo you something for helping with this.

  • Yes, I did try that earlier today, with no luck. Was just trying to follow what that page link said and I noticed their missing “s” in some places. At this point, ACF has entirely quite offering any output at all in my template. (unordered or otherwise) I have obviously flubbed something up.

  • 
    $site_features = get_field('site_features');
    if( $site_features ): ?>
    <ul>
        <?php 
    // notice the missing "s"
    foreach( $site_features as $site_feature ): ?>
            <li><?php echo $site_feature; ?></li>
        <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    

    What does this do?

    
    foreach( $site_features as $site_features ):
    

    The first iteration of this loop sets $site_features (an array) to the string of whatever is in the first array value. This is the same as doing

    
    $site_features = $site_features[0]
    

    and this breaks your loop. Lets say that the first value of that array is “Some String”, then the next itteration will set $site_features equal to the second character of the string.

  • I don’t understand what you mean by “the intrinsic size”. What part of the image tag are your referring to?

    
    <img
    loading="lazy" src=".../test-the-kings-wark-pub-historical-pub-edinburgh-741x1000.jpg" width="741" height="1000" alt=" Image of dish at The Kings Wark pub" title="test-the-kings-wark-pub-historical-pub-edinburgh" class="size-medium wp-image-249" srcset=".../test-the-kings-wark-pub-historical-pub-edinburgh-741x1000.jpg 741w, .../test-the-kings-wark-pub-historical-pub-edinburgh-1037x1400.jpg 1037w, .../test-the-kings-wark-pub-historical-pub-edinburgh-768x1037.jpg 768w, .../test-the-kings-wark-pub-historical-pub-edinburgh-1137x1536.jpg 1137w, .../test-the-kings-wark-pub-historical-pub-edinburgh.jpg 1481w" sizes="(max-width: 741px) 100vw, 741px" /></div><div
    class="lower-image">
    

    The image tags look as I would expect them to look.

  • Now seems to work. Do I need to re-save all my posts again manually in order to have this rules applied?

    May I add something to my question? Maybe it explain better my issue:

    I am getting those posts in my CPT from somewhere (is an external software). The posts are automatically saved in WP with a title that looks like: title-one-2345

    Is it possible to apply the rule you proved above automatically?

  • This is how I would do this…

    The basics

    Upload all of the flag images to a folder on the server, for this example I will assume I have put them in /wp-content/themes/your-theme/flags/. The file names of these flags would include information I want to display. For example the file name for the US flag might be “US-USA-United_States.png”. I will explain US is the 2 character ISO country code, USA is the 3 character ISO code and ‘United_States” is the country name. These 2 parts are separated with hyphens and spaces are replaced with underscores. You can use whatever you want here based on what text you want to appear for selection.

    I would create a select field for the flag. “Stylised UI = Yes” this will allow images to be shown and will also create search using select2.

    I would dynamically generate the choices for this field from the files that exist in the folder.

    
    add_filter('acf/prepare_field/name=your-flag-field-name', 'populate_flag_field', 20);
    function populate_flag_field($field) {
      $choices = array();
      $dir = get_template_directory().'/flags';
      $files = scandir($dir);
      if ($files) {
        foreach ($files as $file) {
          if (is_dir($dir.'/'.$file)) {
            // skip folders
            continue;
          }
          // only allow png images
          $file_info = pathinfo($file_name);
          if ($file_info['extension'] != 'png') {
            continue;
          }
          // build label
          $label = $fileinfo['filename'];
          // pretty it up
          $label = str_replace('-', ' - ', $label);
          $label = str_replace('_', ' ', $label);
          // add image
          $label .= ' <img src="'.get_template_directory_uri().'/flags/'.$file.'" />';
          // add choice
          $choices[$file] = $label;
        } // end foreach file
      } // end if files
      return $choices;
    } // end function
    

    The I would create an acf/format_value filter

    
    add_filter('acf/format_value/name=your-flag-field-name', 'format_flag_field', 20, 3);
    function format_flag_field($value, $post_id, $field) {
      if ($value) {
        $value = '<img src="'.get_template_directory_uri().'/flags/'.$value.'" />';
      }
      return $value;
    }
    
Viewing 25 results - 5,351 through 5,375 (of 21,337 total)