Support

Account

Forum Replies Created

  • aja, you need to share some fields of a repeater already created into some new field group? that´s it?

    You have a “clone” field, don´t know if it´s only available on ACFPro i only use that version, but with that “clone” field you can just do that, clone some fields into some new group.

    So, you don´t need to create a new repeater on the new field group, just create a clone one and choose the old repeater to clone. From front-end side will be almost the same thing you already have. See documentation better to understand how it works, not hard at all.

    Good luck!

  • About your first question, when your “desde” field is empty, it will return the today date same way if i do this:

    $date = new DateTime();

    You should make a condition to test if $date is not empty, like:

    
    <?php $date = get_sub_field('desde', false, false); 
    if($date){
    $date = new DateTime($date);
    echo $date->format('d/m/Y'); 
    } ?>
    

    Second question…. not clear what you mean 🙂

  • You should use get_sub_field() to get the value into a variable, this way:

    <?php
    $style = "";
    $code_snippet = get_sub_field('code-snippet');
    if(empty($code_snippet)){
       $style = 'style="display:none;"';
    }
    ?>
    <div class="content-code" <?php echo $style;?>>
        <article>
            <pre>
                 <?php echo $code_snippet; ?>
           </pre>
        </article>
    </div>
    
  • I made something similar here: http://orihuelainmobiliaria.com/

    The map render markers that are in fact the results on the right. The api has also a clustered extencion to group markers if are closer and zoom makes them to be visible overlaped (many listings sites uses this technique)
    I see on your design that you need something related to how “close” will be the location, the 0km – 500km selector. That´s something you can´t do only on php and js on the theme, this needs to be filtered once the map is rendered since will be a second search right on the map api.

    The rest, the first filter, input and location, that is something you can do using a custom query with multimple meta post. That´s is those custom fields with City, State, zip/post code and the map coordinates (acf fields yes)

    Your request is too particular, i don´t know (and have no time), how to explain this in more detail. Will be too long also, we are talking about all sides, php, js, ajax, custom query results, google api… Everything is documented, in fact i learned how to do that looking for on many resources and then mixing the things.

  • You can add a map field on products of course. The other part depends on google api and theme coding in order to create a search input to find on your “locations”. You need to be more specific on what is locations in this case. Something you add as a metadata to the map, like a name or title? Or by ID, or by product name…? could be many things if i started to think into this.

    You may take a look into this things i guess:

    http://jsfiddle.net/1dd3ss5p/2/
    https://jsfiddle.net/upsidown/1svw299r/

    Both has a finder, but they are searching for diferent things.

  • You should use “google_map_marker_args” filter to change the icon, that is, into the marker itsefl, the google.maps.Map that uses “google_map_args” fitler, has not options for icon marker.

    About style args, did you test using args[“styles”] = styleArray; ?

  • Not easy but not imposible, i´m familiar with QTranslateX, i can provide you with just the basics and then you need to find they way to make it work better, for example, you must use the same key and different values (translated), not the way you tryied, so, this:

    Air Conditioning : Air Conditioning

    It´s wrong, because, first, key should be something like “air-coditioning”, this is the key you will later use on front-end to get the value.

    In order to make it traslateable, then write this:

    air-coditioning : [:en]Air Conditioning[:es]Aire Acondicionado

    At that point you will see, on admin side, this on the select option value:

    [:en]Air Conditioning[:es]Aire Acondicionado

    So, let´s make qTranslate available for that, this way, in your functions.php add something like (if your field name is “checkboxCarFeatures”):

    function acf_custom_select_qtrans_fx( $field ) { 
    	global $q_config; 
    	$field = qtranxf_use($q_config['language'], $field, false, false); 
    	return $field;	 
    }
    add_filter('acf/load_field/name=checkboxCarFeatures','acf_custom_select_qtrans_fx');

    Little explanation.

    The global $q_config var is a qtranslate global var already defined with plugin, the qtranxf_use function is also a plugin function. So, you should code this with some conditionals to see if qtranslate is installed, in your hands that part 🙂

    The acf load field filter just use in this case the name (checkboxCarFeatures), once that field is loaded it will execute the function acf_custom_select_qtrans_fx that only takes the $field and apply the qtranxf_use functions that makes those [lang:] tags to work.

    Ok, that´s easy right? But, take in consideration this will only works once you load a page in some lang, not when switching with the lang switcher buttons, qtranslate has the option to not load admin page once you switch, if using this, option select will not change the lang, for that you will need more code using some js to make that to happen, that´s is, triggering the lang switch some way to apply the filter on those select options, by default it will not change. Try it and you will notice what i mean. I didn´t get deep into that, but qtranslate has js hooks and functions that can do that, i guess; like: qTranslateConfig.qtx.addContentHookC(field, form); Make a resear and sure you will find how to make switch buttons to change translated texts on those selects.

    On the front-end, once you take the value, if it´s not translated and you see the [lang:] tags, is just to apply same filter logic using qtranxf_use() function for example.

    Good luck

  • Hi James, you know? it´s happening again, i have only 4 pages, using just in one of them, 2 flexible layouts with really not too many fields… 11 seconds to save.

    I thinks it´s something with js that takes a lot of time checking one by one if some has change… is that correct?

    If that, there must be a way to avoid it and only save directly the ones changed. The changed status could be something applied to the field once is changed, like adding a class “changed”, then, the save process will only take those “changed” fields to save, and no need to check one by one. Or i´m missing something important behind the script that can´t do that way things?

  • Thanks so much James, sorry for taking your time since in fact now i realised this is nothing to do with ACF. But i thought could be something into the acf/save_post that i was missing.

    The idea you talked is similar what i first did and i think i´m going to do it that way at the end.

    All this think was becuse YOAST uses de post_content to analize things on the post edit screen, and tested some other things with yoast filters to let the custom fields to be analized, but no luck into that, so, i ended doing this thing with acf/save_post using the same front-end template to save the post_content.

    By the way this way makes the thing available to any other SEO plugin that uses the post_conntent. And in fact if i develope it more, i will able to use just the_content() on the template, since all the html is there on the saved post_content…. one day i will leave this on github, is like a page builder using flexible content, and i have all programed so the only thing i need to do is create a new layout and a template with same name, ready to use with just a few clicks 🙂

    At this moment i have created many layouts that are very general, so i can use them on almost any site and not creating custom particular things for every site. A lot of time saved when developing.

    Well, that´s all, have a nice day.

  • Ok, this is the entire function:

    function builder_save_post($post_id){
    	
    	global $post;
    	global $saving_build;
    	$saving_build = true;
    	$builder_post = array();
        $builder_post['ID'] = $post_id; 
    	
    	if ( ! wp_is_post_revision( $post_id ) ){ 
    	
    		$set_template = get_post_meta( $post_id, '_wp_page_template', true );
    		
    		$do_build = false; 
    		$builder_out = '';
    		
    		if( '_template-acf-builder.php' == $set_template && have_rows('bc_builder') ){ 
    			$builder_out .= '<div class="bc_builder">'; 
    			while( have_rows('bc_builder') ){
    				the_row();
    				 
    				$layout = get_row_layout(); 
    				 
    				if( !empty($layout) ){
    					ob_start();
    					get_template_part('layout/builder', $layout.'-save_post'); 
    					$builder_out .= ob_get_clean();
    				}
    			}  
    			$builder_out .= '</div>';
    			$do_build = true;
    		}
    		
    		$builder_post['post_content'] = $builder_out; 
    		
    		if($do_build){ 
    			remove_filter('acf/save_post', 'builder_save_post', 20);  
    			wp_update_post( $builder_post );
    			add_action('acf/save_post', 'builder_save_post', 20); 
    		}
    		
    		$saving_build = false;
    	}
    }
    add_action('acf/save_post', 'builder_save_post', 20);

    As you can see i´m using get_template_part to get php files iniside /layout/ folder, this templates are named with same name of the flexible layout ($layout variable).
    So if layout is “gallery”, the template is layout/builder-gallery-save_post.php.

    It works perfectly, data is saved the right way. But….

    Let´s say i inside on of those templates i have something like this:

    The title: "<? the_title() ?>"
    The shortcode: <? echo do_shortcode('[shortcode]'); ?>

    Where “shortcode” is just an example, could be any shortcode. Let´s imagine that this shortcode outputs only a string like “Hello”, so, this is what is saved into the post_content till now:

    Post title: "My post title"
    The shortcode: Hello

    The last “The shortcode: Hello” is the problem, i don´t whant the result of the shortcode, i want this to be saved into post_content:

    Post title: "My post title"
    The shortcode: [shortcode]

    That´s it, i need to save just “[shortcode]” into the post_content, not the “Hello” result that this shortcode returns. So, i guess there´s must be some way to unfilter the do_shortcode before i get the template part or something like that.

    Sorry, it´s a complex situation and is hard to explain 🙂

  • Thanks James, sorry but i ended up resolving on a different way without clone fields and i don´t have the json file anymore.
    But i will keep on testing this on my next project or even better, i will try to find some extra time to create all this particula situation again and then yes, i could provide you with a json file/s to test.

  • Hi, everybody, i was experienced some slow issues too. But, i discover something or that´s what i think.

    – I´ve started creating a new theme, custom functions, new field groups, flexible content, etc. I didn´t have so many content, not so many fields too, in fact i get the slow issue just with a page using two flexible layouts. At some point everytime i´ve save a post/page, takes too much to save, something like 10-20 secs. But only if i change something, custom fields, content, title. If nothing changes and click save, it takes just a second.

    – I disabled all plugins. Nothing changed, even an empty page with just some “ops” text to save into content, takes about 20 seconds to finish the save action and refresh the page.

    – I disabled my custom theme and actived twentyfiftyn. Same thing… slow on save (but just if somethig changes on the content, title, etc) So, no ACF running, no other plugin running, twentyfiftyn installed only, and still slow ?¡?¡

    – This happened localy and on server, has no difference.

    At that point i realised that has nothing to do with my local settings, my custom theme, flexible or repeated fields, php version or anything else because i ended up re-instaling wp with a new empty ddbb, then i instaled and active ACF, and then my custom theme, filled some data width some flexible content and so on, and guess what? Now saves normaly, quick.

    So, what you think? It seems that something in the ddbb was causing the slow thing? May be yes, something created by ACF, fields not longer used, or data on the post meta table that was missed or something like that?

    Using ACFPRO 5.4.1 and WP 4.5.3.

  • I guess you can start looking into this to get the “type” for any field, and “parent” to know if the field is a repeater subfield:
    https://www.advancedcustomfields.com/resources/get_field_object/

  • Oh!!, can´t belive i didn´t notice that 🙂
    Thanks so much John, working!

Viewing 15 posts - 26 through 40 (of 40 total)