Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • @luiscolome confirmed via support ticket that the issue is ongoing. I’ve requested they add this to the documentation. It look me a bit of searching to find this forum post.

  • thank you, this was exactly what I was looking for and it answered my question.

    I’m using Oxygen Builder so i dont have access to the header.php or theme pages which made me put the acf_form_head() in the functions.php file and the init hook callback works like a charm!

  • You need to use the ID of the related post (the project) in your query instead of the ID of the current post (the session). get_the_ID() is returning the ID of the current post.

  • Like I said, I’m not sure. I believe that the fields are save to a specific block ID on the page. This makes each field unique to that ID. If you’re not seeing issues in the editor then you probably won’t see issues elsewhere.

  • Thanks for a quick reply!

    I know that on the first look it doesn’t mess with the fields and it looks good. I was just wondering if it can mess deeper and cause any other problems than just bad displaying of the fields.

    Either way, thanks!

  • To do this you need to create custom location rules.

    I do not have existing code for exactly what you are looking for. There are many examples of doing this on the web, but not exactly this.

  • You would have to use an acf/load_field filter or an acf/prepare_field filter.

    In this filter you would have to use the field value $field['value'] which will hold an array of Post IDs. You would use this and do a WP_Query() using the value in the post__in argument and the ‘post_status’ argument set to ‘publish’ and replace the
    field value with the IDs of the posts returned.

  • I have not used either method so take this with a grain of salt.

    I believe that the plugin ACF to REST API adds the custom endpoint mentioned /wp-json/acf/v3/options/options

    WP is not likely to add an endpoint that relates specifically to ACF Options Pages.

    I can find no mention of an endpoint for getting options using the WP Rest API, but this is what you are looking for. As far as I can tell this does not exist.

    ACF options are store in the wp_options table, generally with the option_name of "option_{$field_name}" although this will be different if you specify a custom string as a post ID and will use that ID instead of “option”

  • Actually nevermind. I made further tests and there’s another issue laying around and it still triggers validation for the other forms… basically can’t have multiple forms with required values anyway (which makes sense in the admin, but not on the frontend). I’ll have to resolve the issue differently 🤔

  • I see I see. It’s a simple newsletter subscription form which is displayed in the header / overlay navigation of the website as well as in the footer.

    No worries, I’ll resolve the issue by duplicating the form and fields, it’s not a big deal for now and could even actually give us an insight on which of those two gets used the most.

    Thanks for replying so quickly! 👍

  • 
    <?php
      $today = date('Y-m-d');
      $last_of_month = date('Y-m-t');
      $args = array(
        'posts_per_page'  => 7,
        'post_type' => 'competicions',
        'orderby' => 'meta_value',
        'order' => 'asc',
        'meta_key' => 'datahora_prova', //ACF date field
        'meta_query' => array(
          array(
            'key' => 'datahora_prova', 
            'value' => $today, 
            'compare' => '>=',
            'type' => 'DATE'
          ),
          array(
            'key' => 'datahora_prova', 
            'value' => $last_of_month, 
            'compare' => '<=',
            'type' => 'DATE'
          )
        )
      );
    
  • I don’t see anything wrong with those query args or a reason it should not be working.

  • It returns this:

    Array
    (
        [posts_per_page] => 7
        [post_type] => competicions
        [orderby] => meta_value
        [order] => asc
        [meta_key] => datahora_prova
        [meta_query] => Array
            (
                [0] => Array
                    (
                        [key] => datahora_prova
                        [value] => 20220706
                        [compare] => >=
                    )
    
                [1] => Array
                    (
                        [key] => datahora_prova
                        [value] => 20220731
                        [compare] => <=
                    )
    
            )
    
    )
  • yes, it looks right. Like I said, I don’t see anything wrong with it. From what I know it should be working.

    Before doing the query add

    
    echo '<pre>'; print_r($args); echo '</pre>';
    

    to double check what it actually looks like and if it’s right.

  • Thank you, but the code returns me nothing. Have I miss something?

    <?php
      $today = date('Ymd');
      $last_of_month = date('Ymt', strtotime(date('Y-m-d')));
      $args = array(
        'posts_per_page'  => 7,
        'post_type' => 'competicions',
        'orderby' => 'meta_value',
        'order' => 'asc',
        'meta_key' => 'datahora_prova', //ACF date field
        'meta_query' => array(
          array(
            'key' => 'datahora_prova', 
            'value' => $today, 
            'compare' => '>=',
          ),
          array(
            'key' => 'datahora_prova', 
            'value' => $last_of_month, 
            'compare' => '<=',
          )
        )
      );
        $upcoming_events = new WP_Query( $args );
        if ( $upcoming_events->have_posts() ) :
    ?>
    
    <?php while ( $upcoming_events->have_posts() ) : $upcoming_events->the_post(); ?>
    
    <div class="widget_next_competicions_title">
    <?php $permalink = get_permalink(); the_title('<a href="' . $permalink . '">', '</a>'); ?>
    </div>
    <div class="widget_next_competicions_date">
    <?php echo get_field('datahora_prova'); ?>
    </div>
    
    <?php endwhile; wp_reset_postdata(); ?>
    
    <?php endif; ?>
  • The first problem you have is that you can’t use “Date” as the meta type because ACF date fields are not stored as “dates” in the database. the type needs to be strings or numbers.

    date('Ymt') will return the last day of the month for a given date.

    
    <?php
      $today = date('Ymd');
      $last_of_month = date('Ymt', strtotime(date('Y-m-d')));
      $args = array(
        'posts_per_page'  => 7,
        'post_type' => 'competicions',
        'orderby' => 'meta_value',
        'order' => 'asc',
        'meta_key' => 'datahora_prova', //ACF date field
        'meta_query' => array(
          array(
            'key' => 'datahora_prova', 
            'value' => $today, 
            'compare' => '>=',
          ),
          array(
            'key' => 'datahora_prova', 
            'value' => $last_of_month, 
            'compare' => '<=',
          )
        )
      );
    
  • Hi @killerfrost and thanks for your reply. Unfortunately my question wasn’t about a CRM, it was about a notes system like the type of notes system you would find in a CRM.

  • From bitter experience (and hard truths), I’d first inquire as to why you require the CRM. In general, if it’s just you and your sales process is straightforward, sticking to something straightforward wins every time – whiteboard, diary, spreadsheet, Trello, or something along those lines. If you’re just starting out, I find that the “benefits” of any SaaS CRM become distractions and waste time. If, on the other hand, you have more than one person on your sales team and/or a fairly complicated sales process (or a high volume), then look into a few freemium platforms that price-scale well with your company. Pipedrive, HubSpot, and SubscriptionFlow have all proven to be quite effective in their own right. If nothing else, I hope this helps someone who is reading.

  • Hi! I’m used ACF PRO on many my projects!

    We often use custom fields for job postings. We have 2 custom post types – Jobs and Contact person. Both connected by relationship and on Job post we select Contact peson.
    Also we have functionality which send to draft job post if Job date is expired.

    On functions.php i add also functionality which remove possibility to select drafted post in relationship globally. Like this:

    add_filter( 'acf/fields/relationship/query','relationship_options_filter', 10, 3);
    function relationship_options_filter($options, $field, $the_post) {
    	$options['post_status'] = array('publish');
    	return $options;
    }

    My problem is that if we select post and after date is expired we have this post on right side of relationship field, which is bad for coding, because in loop we still have that post.

    On backend i add also checking if post have status “published”. Frontend part is ok, but i wat to hide drafted post on right side of relationship field – see image below. Highlighted part must be hidden!

    Tell me please what is possible!

  • How did this turn out? I wish it had been public so I could see, because I’ve experienced the same thing with wc_get_template_part()– it renders an empty block, but if you switch to Preview mode and back to Edit, the block renders fine. It works fine on the front end, of course. If I just individually call for the_title, the_content, the_post_thumbnail, for example, it works perfectly on the back end, but I obviously want all the woocommerce goodies like price etc.

    It’s been this way for quite a while but it’s not a showstopper since you can toggle preview/edit.

  • Hi John,

    Please forget everything mentioned above because the circumstances have changed drastically since my last post. So, here comes the new conditions:

    A custom post type called “agents” is used to retrieve data from an external api, where all the info about each agent is entered and saved.

    I have registered some custom REST fields for all the incoming data (collected by an AJAX call) and then collecting and returning the data for these into any given custom field. This is the code used for that:

    // Register custom Rest field
    add_action('rest_api_init','itc_custom_rest');
    
    // Collect the data from REST and return the given custom field
    function itc_custom_rest() {
        register_rest_field('radgivare', 'minutePrice', array(
    		'get_callback' => function() {
    			return get_field('price_per_minute');
    		},
    		'get_callback' => function() {
    			return get_field('agent_status_available');
    		},
    		'get_callback' => function() {
    			return get_field('agent_status_inCall');
    		},
    		'get_callback' => function() {
    			return get_field('agent_status_loggedOut');
    		}
    	));
    }

    The new fields show up in REST alright.

    My big question now is, can I use the following code in order to echo whatever is retrieved from REST, or do I need to use something else?

    // Example used to echo certain colors and texts if the fields (which are type bool) are true
    <div class="card__btn-block">
                <a href="#" class="btn rounded <?php
                  if (get_field('agent_status_available')) {
                    echo $green_status;
                  }
                  if (get_field('agent_status_inCall')) {
                    echo $yellow_border_status;
                  } else {
                      echo $red_border_status;
                  } ?>">
                  <?php
                  if (get_field('agent_status_available')) {
                    echo 'Call Now';
                  } 
                  if (get_field('agent_status_inCall')) {
                    echo 'In Call';
                  } else {
                      echo 'Offline';
                  }
                  ?></a>
              </div>

    Thank you very much for your superior efforts of helping clueless people like myself!

  • More then likely this is a conflict in select2. See this page https://www.advancedcustomfields.com/resources/acf-settings/, try setting enqueue_select2 to false.

  • Not sure but something like this should work

    
    'meta_query'             => array(
                  'relation'    => 'AND',
                    array(
                      'key'   => 'type_activity',
                      'value'   => 'Sports',
                      'compare' => 'LIKE',
                      ),
                    array(
                      'key'   => 'type_activity',
                      'value'   => 'Works',
                      'compare' => 'NOT LIKE',
                      ),
                  ), 
    
  • I can’t help you much with the query to directly query the DB. That would be over my head. I could probably figure it out but I prefer easier solutions.

    For something like this I would create an acf/save_post action. In my filter I would get the values from the related posts that I want to base a search on and store them in WP custom fields connected to the posts I want to search. Here is an only explanation of doing that https://web.archive.org/web/20190814230622/https://acfextras.com/dont-query-repeaters/. The link deals with repeater fields but it can easily be applied to this case as well.

  • Just to clarify, you wrote:

    In order for fields to appear and for there to be a location the page must be either post type of a taxonomy.

    Did you mean: “the page must be either a post type or a taxonomy?

Viewing 25 results - 4,201 through 4,225 (of 21,339 total)