Support

Account

Forum Replies Created

  • thank you very much!
    At the end I am using a simple textfield to save the title of a custom post type.

  • Maybe the ACF-Page-Link delivers a flat url? Right?

    If so, how can I select a cpt via an acf-field? I started a new thread:
    https://support.advancedcustomfields.com/forums/topic/it-is-possible-to-select-a-custom-post-type-via-acf/

  • thank you so much for your outstanding support!

  • Hey thank you!
    I want to organize the subfields of a repeater in tabs. So that I will have a new tab if i create a new repeater item.

    I have a repeater called “pages” with a flexible-content subfield called “elements”.

    In the end it would be great to get tags for every “page”

    like:

    [Page 1] [Page 2] [Page 3] ……

    > flexible content subfield for page x

    thanks so much!

  • Hey,
    I know that this is not a new question but I dont find a good solution in the forums. That is why I start this Topic.

    I want to organize the repeater fields in tabs (or something similar) in order to make the backend more clear.
    Is there any reliable workaround?

    That is the backend for now

  • Hey John

    this setup looks really interesting. I like to do something similar:
    I want to organize the items of a flexibel content field in this nice layout that do you have on the left side. But I dont figure it out, can you give me a hint?

    edit: I want to add the tabs dynamically. I found this https://github.com/JamesParkNINJA/acf-repeater-tabs and i will test it.

  • Thank you!

    Okay, maybe it is a better idea to use the duplicate field functionality of acf?
    Is it possible to add a new function that will do the same what the duplicate field function does but append another string (like “en”) to the new fields name? For example “duplicated-field_en”.

  • Sorry i was to fast to select your answer as the solution.

    unfortunately pre_get_posts does not work with previous_post_link and next_post_link as far as i can say at the moment. It seems that maybe get_adjacent_post will do the trick but how do i have to write a get_adjacent_post function that will work with meta_key and orderby?

  • Hi James
    another further question: is it possible to show the extra HTML before the label or after the input? At the Moment I get it only between label and input.

    Thanks alot!

  • Thanks alot, is it also possible to add information to the render field wrap? For example at the beginning or end of the fieldgroup? Would be great to know!

    Thanks alot for your help!

  • I thought i can use acf/render_field only to control a certain type of field or all fields, how can I use this with a field-Id or with a field-name?

    like this:
    add_action( ‘acf/render_field/key=FILDKEY’, ‘action_function_name’, 20, 1 );

    thanks alot!

  • Part 2:
    I have a futher question: is it possible to provide in the backend a possibility to have a second field for a translation on demand? Lets say, i have some fields with text and for this certain fields i have a button that says something like “need to translate” and by clicking this button a field will be created (named like the original field plus prefix/suffix).

    Or is it better (for performance / databse…) to decide width fields should or could be translate and to provide a second field for all this fields.

    Or is it better to work with a conditional logic, to provide a second field?

    thanks alot!

  • this is absolutely great!

    I am testing this and its looking very promising,
    f.e. because it can be used more specific (f.e. for a certain field) and is not that general.

    at the moment i have this:

    Links in header.php

    <?$data = array('lang'=>'en');?>
    <a href="?<?echo http_build_query($data) . "\n";?>">English</a>
    <?$data = array('lang'=>'ger');?>
    <a href="?<?echo http_build_query($data) . "\n";?>">Deutsch</a>
    

    in functions.php I set a cookie from the links above

    
    ///// Set cookie
    add_action('init', function() {
    global $language;	
    	
    	
    /////set cookie from GET:
    	
    if(isset($_GET['lang']))
    {
    $lang = $_GET['lang'];	 	
    setcookie('lang', $lang, strtotime('+1 day'),"/", false);
     }
    		
    ///receive value from cookie and get	
    if (isset($_COOKIE['lang'])){
    		  
    echo "<br>cookie:<br>";
    echo $_COOKIE['lang'];   
      
    $language = $_COOKIE['lang']; ///sanitize this later… 
    } 
    
    if (isset($_GET['lang'])) {
    echo "<br>GET:<br>";
    echo $_GET['lang'];  
    $language = $_GET['lang']; //// sanitize
    		
    } 
    
    echo "<br>language global is: ".$language."<br><br>";		
    
    });
    //// end set cookie
    

    in the post template i use this

    	<? echo get_multilingual_field("haupttext"); ?>
    

    and in functions.php i declare the function like this

    
    ///multilanguage field
    function get_multilingual_field($field_name) {
    global $language;	
    
     $value = get_field($field_name.'_'.$language, false, false);
        if (!$value) {
            // no value returned for language
            // get the default
    		
    		
    			// no translation print out a message		
    			if ($language=="en")
    			{
    	        $value = "Sorry, no translation available<br><br>";
    		
    			}		        
            $value.= get_field($field_name,false, false);
        }
    
        return $value;
    }
    	
    

    i can use this approach very flexible, for example
    i have a function to show the date
    and i can modify it to show german/american date very easily

    
    function datumzeit($id) {
    global $language;
    /////std date		
    $folge_std_min= 'j.n.Y, H:i \h';
    
    if($language=="en")
    {
    $folge_std_min= 'n.j.Y, h:i A';
    }		
    $timestamp = get_field("zeitstempel", $id);
    echo date($folge, $timestamp);
    }
    

    i also have a switch function to translate a certain field (based on a dropdown list)…

    and so on, thank you so much for your help!
    what do you think is this a good way to do this?

    PS: Sorry for the not so nice code and the debug-infos…
    PPS: to use this all echos in the first function need to delete

    PPPS: I just disabled wpml and the performance is insane. Backend loads in 2,4 sek. With wpml / string translation etc the loading time was 8 sek!

  • Hey! thank you very much, this sounds good!
    I tried it like this, at the moment the query does not run but I have an array with all ids of posts in relationship. What do you think, will this work solid?
    Why the query is not updating?

    the code is just a sketch at the moment:

    
    function ingruppe_pre_get_post( 	$the_query ) {
    
    	 wp_reset_postdata();
    
    	
    	$alle_posts_in_gruppen = array();
    
    if( ! is_admin() &&	$the_query->is_main_query() ) {
    	
    	$check_in_gruppe = get_posts(array(
     		'posts_per_page' => '-1',
     		'post_type' => array ('veranstaltungsgruppe'),
     		'meta_key' => 'veranstaltungen',
     
    
     				
     		));
    
    	foreach ($check_in_gruppe as $check_in_gruppe_i){
    		
    			$beziehung = get_field('veranstaltungen', $check_in_gruppe_i->ID);
    			
    			foreach	($beziehung as $beziehung_i) {
    				
    				$alle_beziehungen [] = $beziehung_i->ID;
    				
    			}	
    	}
    	
    	echo "<br>exclude this posts because they are in relationship: <br>";
    					print_r($alle_beziehungen);
    
     			$the_query->set('post__not_in', $alle_beziehungen);
     			
     			
     			///test Query dont update…:
    			$the_query->set('posts_per_page', 1);
    
    

Viewing 15 posts - 1 through 15 (of 15 total)