Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • There will be around 2000 “Programmes” in the DB…

    I’ve found another way to do it. Maybe not the best way or the cleanest but hey, it works !

    <?php foreach($produits->posts as $id):?>
       <?php if( have_rows('prix',$id)): ?>
    
          <?php /*If Typology AND Price are selected in the search engine */ ?>
          <?php while( have_rows('prix',$id) ) : the_row();?>
              <?php if((!empty($_POST['typologie']) && $_POST['typologie'] == get_sub_field('typo_prog')) && (!empty($_POST['prix']) && $_POST['prix'] > get_sub_field('prix_prog'))):?>
    
                     <a href="<?php the_permalink($id);?>" class="produit col-md-4">
                        MY CONTENT
                     </a> 
               <?php endif;?>
            <?php endwhile;?>
    
       <?php /*If Typology or price are NOT selected in the search engine */ ?>
        <?php if(empty($_POST['typologie']) || empty($_POST['prix'])):?>
    
           <a href="<?php the_permalink($id);?>" class="produit col-md-4">
              MY CONTENT
           </a>
        <?php endif;?>
    
      <?php  endif;?>
    <?php endforeach;?>
  • Thinking about it, it might be possible, but it could cause a performance issue.

    If you have a limited number of rows in the DB for this. In my example let’s say that there are no more than 2 rows in the repeater

    
    $meta_query = array(
      'relation' => 'OR',
      // first potential row
      array(
        'relation' => 'AND',
        array(
          'key' => 'prix_0_typo_prog',
          'value' => $_POST['typologie'],
          'compare' => '=',
        ),
        array(
          'key' => 'prix_0_prix_prog',
          'value' => $prix,
          'type' => 'NUMERIC',
          'compare' => '<='
        )
      ),
      // second potential row
      array(
        'relation' => 'AND',
        array(
          'key' => 'prix_1_typo_prog',
          'value' => $_POST['typologie'],
          'compare' => '=',
        ),
        array(
          'key' => 'prix_1_prix_prog',
          'value' => $prix,
          'type' => 'NUMERIC',
          'compare' => '<='
        )
      ),
      // continue for every potential row
    );
    

    But if you have too many rows and too many nested queries it will eventually time out.

  • Hi Dennintion,

    Thanks for the follow-up.

    I am using buddypress groups tabs creator pro.

    https://buddydev.com/plugins/buddypress-group-tabs-creator-pro/

    It is an excellent plugin, and very simple to use. Unfortunately it cannot point to unqique urls and keep the group header, thus I need to input via dynamic content section and use shortcodes.

    Hope that makes sense.

    Best regards

    John

  • There isn’t any way, using a query, to associate rows, unless you do 2 or more queries.

    First you need to get the posts that have one of them, for example, get all the posts with “T5”. Then you need to get the row index and then do another query for the other field using this row index. Also, you cannot do this second query on more than a single index, so if “T5” does not occupy the same row index on all posts you’ll need to do multiple queries here.

    Basically, what you’re trying to do is pretty much impossible using repeaters.

  • 
    <?php
    /*
    Template Name: Coaching (Flex Layout)
    */
    
    get_header();
    ?>
    
    <?php
      if( have_rows('coaching_flex_sections') ):
      
      // not needed
      //$sections = get_field( 'coaching_flex_sections' );
    ?>
    
      <div class="coaching flex-sections">
        <?php
          while( have_rows('coaching_flex_sections') ): the_row();
            // while( have_posts() ): the_post();
              
              // Loop through flexible fields and load the respective file for each.
              
              // double loop over rows -- remove
              // foreach( $sections as $i => $section ) {
    
                // change to get_row_layout()
                $part = get_stylesheet_directory().'/_template-parts/flex-layout/sections/'.get_row_layout().'.php';
    
                if ( file_exists( $part ) ) {
                  include( $part );
                } else {
                  echo '<!-- Error: No such flexible field type "'. esc_html($section['acf_fc_layout']) .' at '. esc_html($part) .'" -->';
                }
    
              // } // end of nested double loop - remove
            // endwhile;
          endwhile;
        ?>
      </div>
    
    <?php endif; ?>
    
  • It depends on where you’re adding code.

    If you are enqueuing a JS file then you need to set the $deps argument to array('acf-input') and you should also enqueue scripts on the acf/enqueue_scripts hook for any scripts you’re adding for ACF.

    If you are putting code into the page the something like this usually works

    
    (function($){
      // your code here
    }(jQuery)
    

    More information here https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/

  • I also tried deactivating all plugins except for ACF Pro during this process. So I was at a loss as to what could be the issue.

    What I then tried was to bring up my local dev environment version of the website and decided to leave the database untouched but synchronize the custom field groups with the acf-json files. When I did that, even though the field group in question had changed dramatically and the synchronization added to older unused versions of the field group, the field group showed the missing layout.

    So I’m not sure what exactly was the issue but it seems that the pending synchronization with acf-json caused some issue. Once I did the same action on the live server, the layout showed correctly. Additionally, I was able to delete the old field groups that synchronized without harming my other data etc.

  • @hube2 thanks for the quick response. I don’t believe that is the problem since I just updated the phprc, which is what this Dreamhost server is using, to include the following:

    ; {{{ The following lines were automatically added by DreamHost
    zend_extension=opcache.so
    memory_limit=500M
    ; }}} That's all from DreamHost
    
    max_input_vars = 5000
    max_input_nesting_level = 128
    max_execution_time = 300
    post_max_size = 32M
    max_input_time = 300
    suhosin.post.max_vars = 8000
    suhosin.request.max_vars = 8000

    I can verify that everything except the suhosin settings are applied. I’ve tried updating both post and custom field group and nothing is changing. Anything else you can think of?

  • 
    <?php
         $uf_field = get_field_object('field_5fff35040e0f4');
         if($uf_field) :				
              echo '<select name="estado"><option value="" disabled selected>ESTADO</option>';
              foreach($uf_field['choices'] as $value => $label) :
    	       echo '<option value="' . $value . '">' . $label . '</option>';
    	  endforeach;
    					
    	  echo '</select>';
         endif;
    ?>
    
  • You may be having an issue with PHP’s max_input_vars setting. https://www.google.com/search?client=firefox-b-1-d&q=acf+php+max_input_vars

  • Thank you for the quick response John, I really appreciate your help.

    I understand that shortcodes are set-up for simple fields, but it is working in the_content section of a page I have to use.

    The output can be seen here.https://legally-linked.com/groups/clifford-chance/law-firm-technology/

    All the boxes are showing the array via shortcode.

    I have had a look at the format value link you sent, not sure what to add to functions.php

    Something here for shortcodes for select or array fields

    // Render shortcodes in all select values.
    return do_shortcode( $value );
    }

    or something with this

    acf/format_value/type={$type}

    It’s not clear how to remove the commas.

    Best regards

    John

  • Hi John,

    Thank you for your help, I have only just seen the response.

    I have got around the issue by using shortcodes function, after setting-up a custom post type.

    Although it states in documentation that you can only use the shortcode function for text fields, it is working as required with a select field. We have put code in to the value choices.

    The only issue now is that the array is showing a comma after each value and we can’t seem to get rid of it. Do we need to update the shortcode function.

    I can send you the custom post type code and use of shortcode in a content section.

    Best regards

    John

  • If you are using any script file and getting “Uncaught ReferenceError:” which means ‘x’ is either a variable or a method which you are trying to use before declaring it using var keyword. This means that there is a non-existent variable referenced somewhere. This variable needs to be declared, or you need to make sure it is available in your current script or scope otherwise , it will endup throwing this ‘x’ is not defined error . This usually indicates that your library is not loaded and JavaScript does not recognize the ‘x’.

    To solve this error: Load your library at the beginning of all your scripts.

    There can be multiple other reasons for this issue:

    Path to CDN library you included is not correct
    The library file is corrupted
    Working offline
    Conflict with Other Libraries

  • Interesting. I just tried that on a locally hosted copy and yes. These blocks don’t load on WP5.5.3, but they do on WP5.6.

    That’s a bug right there, surely? Is WP5.6 required for ACF now?

  • And the other question is…. Can I show them in any section of the web? The idea is to show this content at the end of the page and not within the default price.

  • You should be able to use this filter to set the order and orderby parameters of the query. https://www.advancedcustomfields.com/resources/acf-fields-post_object-query/

    Here is code from ACF that shows the defaults used

    
    // defaults
    	$args = wp_parse_args( $args, array(
    		'posts_per_page'			=> -1,
    		'paged'						=> 0,
    		'post_type'					=> 'post',
    		'orderby'					=> 'menu_order title',
    		'order'						=> 'ASC',
    		'post_status'				=> 'any',
    		'suppress_filters'			=> false,
    		'update_post_meta_cache'	=> false,
    	));
    
  • Thanks for pointing me right direction. Return format is set to both because the data is used in another query.

    I rewrote to loop through the array, data is now showing.

    <td>
      <?php foreach ($colors as $color): ?>
        <?php if($color['value'] == 'red') { ?>
          <span>✔</span> // html checkmark
        <?php } ?>
      <?php endforeach; ?>
    </td>
  • i have the same issue.

    i am using get field for category but not working

    get_field('some_field', 'category_categoryID')

    simply not working.

    i have changed that category is not the category for standard posttype but for custom posttype. maybe thats the reason?

  • I’m using both Prefix Field Labels and Prefix Field Names.

    One clone is a single one, then there is a repeater containing another clone. I’m assuming you can use a clone in a repeater (pretty sure I’ve seen that in the documentation)?

    Also, I’m using other clones throughout the website, but don’t seem to notice any issues like this, so that’s why I was wondering whether this error is unique to it being on the Options Page? (and some ‘mixed up’ errors in the Options Page relate to non-cloned items, too)

  • Hi John, thanks for the reply.

    Is it relevant how I’m getting the field (using get_fields()) when the issue I see is in the display of the Options Page itself (regardless of how the settings are used within the website)? The options all tend to be within groups, so are accessed using get_sub_field() calling each field by name, so I don’t think there’d be any conflict there.

    The mixing up of the fields only tends to happen when I add a new field within the Theme Options page, but I don’t notice any issue until I view the Options page and configure the new field, then save. This messes up (for example) the colour schemes I have… there are lots of options of colours to set, and today (and in the past) the colour values seem to be shifted by 2 fields. (I’m not quite savvy or confident enough to edite the SQL tables to correct this, so I have to copy and paste all colour values along 2 over several tabs – doable, but a pain).

    The data mixing isn’t restricted to the colours – other options are mised too (text fields suddenly have hex values rather than titles).

    Would it be relevant that: a) the colour schemes are a ‘clone’ field; and b) as well as having a ‘Default’ colour scheme, there are cloned schemes on a repeater for pages/sections with different background colours.

    I appreciate this may be difficult to fully understand from my words… is tere any other specifc information you think I need to provide?

    Thanks John,

    Andy

  • The site no longer exists. You can find the post in the internet archive here https://web.archive.org/web/20190814230622/https://acfextras.com/dont-query-repeaters/

  • Hi John, I find myself in a similar quest as bradpicko; the link you shared to acfextras.com seems to be down and no cache can be found on archive.org nor google would you happen to have a copy somewhere of that post content? Thanks in advance for any help you can provide

  • This is quite interesting question! It would be trully handy if there would be tokens to display in message box.

  • Hi!

    I think I understand, you’re probably trying to query by a custom field.

    Looking at Example 1. from that resource page, it’s very similar to what you are trying to accomplish. Assuming your custom field is attached to some kind of query-able post type like posts or pages (my preference is to create a custom post type) this should be very easy.

    
    <?php 
    
    // args
    $args = array(
    	'posts_per_page' => -1, //get all posts
    	'post_type'	 => 'your_post_type_slug', //posts, pages, whatever the field is attached to
    	'meta_key'	 => 'listing-location', //custom field slug
    	'meta_value'	 => 'New York' //location to count
    );
    
    // query
    $the_query = new WP_Query( $args ); //get WP Query using $args
    
    $count = $the_query->post_count; //use property post_count to return the count
    
    echo 'Location: New York';
    echo 'Total listings I have with that location are '. $count; 
    ?>
    

    The property post_count is available when using a WP_Query. More information here: WP_Query

    Obviously this may not be the most efficient code because the location is hard coded, but maybe that works in your situation.

    My advice would be to set up the listing location as a custom category/taxonomy instead of an ACF field. That way you could loop through all the available categories dynamically.

    Hope this helps!

Viewing 25 results - 6,026 through 6,050 (of 21,330 total)