Support

Account

Forum Replies Created

  • if i dont missunderstood what @semlohj wish it is already possible:
    at backend primary with the help of the clone-field.
    for the frontend with help of includes that contains the reusable block.

    • create option page, that dont need to be accessible for general / by menu
    • create a fieldgroup with all needed fields inside (everything inside repeater but not repeater itself) assign it to that optionpage
    • create new fieldgroup with repeater and add a clone field that use all field from above group
    • create an other fieldgroup/repeater-field/flexible-field and add a clone field that use all field from above group

    with help of that, you can update the original fieldgroup and the changes apply to the clones

    i do for example:
    fieldgroup teaserbox = text,textarea,image,link
    fieldgroup halfcolum = flexible-field with a layout, that include clone-field:teaserbox
    fieldgroup fullcolumn = flexible-field with a layout, that include a repeater with clone-field:teaserbox inside
    fieldgroup content = flexible-field with 2 layout, one inlude clone-field:fullcolum || the other include prefixed clone-field: halfcolumn, prefixed clone-field: halfcolumn

    now i can add another field to teaserbox and fullcolumn, left_halfcolumn, right_halfcolumn where updated

    hope that help. else may @acf-support can reproduce what i say and give a more detailed answer

  • if you dont try to merge your posts into one list you could try this:

    <ul class="program-list">
    <?php query_posts('cat=2'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php
    $repeater = get_field('program_repeater');
    foreach( $repeater as $key => $row ) {
    		$thedate = $row['program_repeater_date']; 
    		$column_id[ $key ] = strtotime($thedate);
    	}
    array_multisort( $column_id, SORT_ASC, $repeater );
    	foreach( $repeater  as $row ){
    
    $dateDayNumber = date_i18n("d", strtotime(get_sub_field('program_repeater_date')));
    			$dateMonthNumber = date_i18n("m", strtotime(get_sub_field('program_repeater_date')));
    			$dateDayOrg = date_i18n("l", strtotime(get_sub_field('program_repeater_date')));
    			$dateDay = substr($dateDayOrg, 0, 2);
    			$dateTime = get_sub_field('program_repeater_time');
    			$specialEvent = get_sub_field('program_repeater_special');
    			$mainTitle = get_the_title();
    			$subTitle = get_field('sub_text');
    			$rowSeatsId = get_sub_field('program_repeater_rowseats_id');
    			?>
    			
    			<li>
    				<div class="specialEvent"><?php if( $specialEvent ): ?><?php echo $specialEvent; ?><?php else: ?>&nbsp;<?php endif; ?></div>
    				<div class="dateDayNumber"><?php echo $dateDayNumber; ?></div>
    				<div class="dateMonthNumber"><?php echo $dateMonthNumber; ?></div>
    				<div class="dateDay"><?php echo $dateDay; ?></div>
    				<div class="v-line-zick-zack"></div>
    				<div class="dateTime"><?php echo $dateTime; ?></div>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
    					<div class="mainTitle"><?php echo $mainTitle; ?></div>
    					<div class="subTitle"><?php echo $subTitle; ?></div>
    				</a>
    				<a href="<?php the_permalink(); ?><?php echo "?id=" . $rowSeatsId; ?>" title="<?php the_title_attribute(); ?>">
    					<div class="ticket-link">Tickets kaufen</div>
    				</a>
    				<div class="clear"></div>
    			</li>
    <?php } ?>
    <?php endwhile; endif; ?>
    <?php wp_reset_query(); ?>
    </ul>

    If you try to merge them => you need to build a array first, order it, and echo it after that.

    try to adapt a solution like this or this

  • if you use all message fields like this,
    than try this: (unfortunately you need to edit corefile)
    /wp-content/plugins/advanced-custom-fields-pro/fields/message.php

    $m = $field['message']; //search this line
    $m = htmlentities($m); //add this line before wptexturize line
  • i don’t know if it is possible to filter at backend without one of this:

    • a additional field that contains the “count”
    • a save date_time-field
    • any other (own) field that you can order by

    where you can order by ASC/DESC

    if you have one of this field, than you can use this how-to to order your repeater

    if it is only for frontend: than it is no need for such a field. just use something like this
    $reversed = array_reverse($your_repeater);

  • dont use the_sub_field inside a “if-check” use get_sub_field instead.
    also dont use echo the_sub_field echo is not necessary there.
    because the_sub_field/the_field are functions that echo per se.
    and get_sub_field/get_field only get/check a value that need to be saved inside a variable for later using.

    try to use one of this codeparts instead of yours:

    if (get_sub_field('email_domain_name') == $dom) {
                    the_sub_field('email_domain_name');
                }
    $emaildom = get_sub_field('email_domain_name');
    if ($emaildom == $dom) {
                    echo $emaildom;
                }
  • if it is url, than:

    $url = wp_get_attachment_url( $attachment_id );
    $title = get_the_title( $attachment_id )

    is false for sure. because it expect you work with ID 😉

    you didn’t answer what values you get from the echos.
    what was output of my code from last post?
    (do you get correct ID and ParentID? and what did you get from get_field?)

    with URL you may can use $attachment_id direct

  • sure. you need to count the images of the gallery, get the difference to 4, and loop through gallery but echo only the last 4 (the others loop without echo)

    something like this:

    $images = get_field('gallery');
    $count= count($images);
    if ($count > 4){
    $i = 0 - $count + 4;
    } else { $i=0;}
    foreach( $images as $image ): 
    $i++;
    if ($i > 0){
    echo $image['url'];
    }
    endforeach;

    not sure if code is correct, but it should help to made a correct one

  • parent post have a filled broschuren-download file-field? (no subfield of a repeater/flex!)
    do you use id or url or object at file-field?

    and what are the values of the different variables?

    <?php
    $post_ID = get_the_ID();
    echo ' id:'. $post_ID;
    $parentpost_id = wp_get_post_parent_id( $post_ID );
    echo ' parentid:'. $parentpost_id;
    $attachment_id = get_field( "broschuren-download", $parentpost_id ); //use parents-post field: "broschuren-download"
    echo ' attachment_id:'. $attachment_id;
    $url = wp_get_attachment_url( $attachment_id );
    $title = get_the_title( $attachment_id );
     ?><div class="pdf-download"><a href="<?php echo $url; ?>" >Broschüre herunterladen</a></div>
  • i think you need to loop through your CP and Repeater and build a array first, and after that echo workshops out of that array.
    important for ordering by date is: that you set Return Format to Ymd (you can change this later with date/date_i18n)

    /*build and fill: cp-loop and repeater loop*/
    if(have_posts()) : while(have_posts()) : the_post(); 
    $my_workshop_name = get_field('my_workshop_name');
    if( have_rows('dates') ):
        while ( have_rows('dates') ) : the_row();
    
    $my_workshop_date = get_sub_field('date');
    $the_ID = get_the_ID();
    
    /*of course you can extend this with additional fields or infos for that workshop that you can use later*/
    $array[$my_workshop_date][$the_ID]['date'] = $my_workshop_date;
    $array[$my_workshop_date][$the_ID]['name'] = $my_workshop_name;
    endwhile;
    endif;
    
    endwhile;
    endif;
    
    /*output*/
    
    asort($array);
    
    foreach ($my_workshop_date as $key_day => $row_day){
    foreach ($row_day as $key_workshop => $row_id){
    $workshop_name = $row_id['name'];
    $workshop_date = $row_id['date'];
    $workshop_date_pretty = date_i18n( 'j. F Y', $workshop_date);
    echo $workshop_date_pretty .' : '. $workshop_name;
    }
    }
    

    hope that help

  • maybe that works / help you

    <?php
    $post_ID = get_the_ID();
    $parentpost_id = wp_get_post_parent_id( $post_ID );
    $attachment_id = get_field( "broschuren-download", $parentpost_id ); //use parents-post field: "broschuren-download"
    $url = wp_get_attachment_url( $attachment_id );
    $title = get_the_title( $attachment_id );
     ?><div class="pdf-download"><a href="<?php echo $url; ?>" >Broschüre herunterladen</a></div>
  • i would use return format: Ymd (better for ordering and strtotime)
    and than use:

    setlocale(LC_TIME, 'de_DE', 'de_DE.UTF-8'); //change to language you wish to display
    $dl_date = get_field('dl_date'); //is $dl_date filled correct? or is it empty?
    $dl_date = (strtotime($dl_date));
    $dl_date_pretty = date_i18n( 'F d Y', $dl_date); //here you can change display of date format 
    //with help of date_i18n you can use setlocale to display a date with language you wish
    echo $dl_date_pretty;
  • i have a working flexslider with acf-gallery.

    I dont know if it make a big difference,(because your code looks not that different than mine.) but i hope it works when you do it this way (like i do)

    register scripts inside functions.php

    <?php
    add_action('wp_enqueue_scripts', 'register_content_scripts');   
    function register_content_scripts(){
    wp_register_style( 'flexslider-custom-css', get_stylesheet_directory_uri() . '/css/flexslider/flexslider.css' );
    wp_register_script( 'acf-flexslider-scripts',  get_stylesheet_directory_uri() . '/js/jquery.flexslider-min.js',  array( 'jquery' ), 1, 1 );
    wp_register_script( 'flexslider-init',  get_stylesheet_directory_uri() . '/js/flex-init.js',  array( 'jquery' ), 1, 1 );
    }
    ?>

    inside gallery-template enqueue them

    <?php
    $images = get_field('slider');
    if( $images ):
    wp_enqueue_style( 'flexslider-custom-css' );
    wp_enqueue_script( 'acf-flexslider-scripts' );
    wp_enqueue_script( 'flexslider-init' );
    ?>
    <div id="slider" class="flexslider">
            <ul class="slides">
                <?php foreach( $images as $image ): ?>
                    <li>
                        <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
                        <p><?php echo $image['caption']; ?></p>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
    <?php endif; 
    ?>
    

    use this inside flex-init.js

    jQuery(document).ready(function($) {
    $(".flexslider").flexslider({
    animation: "fade"
    });
    });

    try it and say if it works

  • use code like this that count images inside the gallery and depends on that count use a if else loop for the different outputs.

    <?php 
    $images = get_field('gallery'); 
    $total_images = count($images); //how many images are inside the gallery
    foreach( $images as $image ): 
    if ($total_images == 1){ //do what you wish i there is only one image
    echo '<img class="h400px" src="'. $image['sizes']['large'].'" alt="'.$image['alt'].'"  title="'.$image['title'].'"  />';
    } else { //do what you wish i there are multiple images
    echo '<img class="h200px" src="'. $image['sizes']['medium'].'" alt="'.$image['alt'].'"  title="'.$image['title'].'"  />';
    }
    endforeach;
    ?>

    depends on your needs choose at least one:

    • use the class and css to style the 2 imagesizes
    • add height param to the image
    • use own/additional media size with the sizes that you wish

    hope that help

  • hi, i think something like that should work

    add_filter('acf/load_value/name=repeater_termin', 'my_acf_load_value', 10, 3); //repeater_name
    function my_acf_load_value( $rows)
    {
     foreach( $rows as $key => $row ) {
      $thedate = $row['termin_date']; //datepicker_fieldname
      $column_id[ $key ] = strtotime($thedate);
     }
     array_multisort( $column_id, SORT_ASC, $rows );
     return $rows;
    }
  • i think you need to loop through your CP and Repeater and build a array first, and after that echo events out of that array.
    important for ordering by date is: that you set Return Format to Ymd (you can change this later with date/date_i18n)

    /*build and fill: cp-loop and repeater loop*/
    if(have_posts()) : while(have_posts()) : the_post(); 
    $get_event_name = get_field('my_event_name');
    if( have_rows('repeater_field_name') ):
        while ( have_rows('repeater_field_name') ) : the_row();
    
    $my_event_date = get_sub_field('my_event_date');
    $get_date = (get_sub_field('my_event_date'));
    $get_date_day = date('d', strtotime($get_date));
    $get_date_month = date('m', strtotime($get_date));
    $get_date_year = date('Y', strtotime($get_date));
    $the_ID = get_the_ID();
    
    /*of course you can extend this with additional fields or infos for that event that you can use later*/
    $array[$get_date_year][$get_date_month][$get_date_day][$the_ID]['date'] = $my_event_date;
    $array[$get_date_year][$get_date_month][$get_date_day][$the_ID]['name'] = $my_event_name;
    endwhile;
    endif;
    
    endwhile;
    endif;
    
    /*output*/
    /*i assume you extract year and month from today (example here next month)*/
    $today = date('Ymd');
    $d = new DateTime($today);
    $d->modify( 'first day of next month' );
    $year_youwish = $d->format( 'Y' );
    $month_youwish = $d->format( 'm' );
    
    $array_month_youwish = $array[$year_youwish][$month_youwish];
    asort($array_month_youwish);
    
    foreach ($array_month_youwish as $key_day => $row_day){
    foreach ($row_day as $key_event => $row_id){
    $event_name = $row_id['name'];
    $event_date = $row_id['date'];
    $event_date_pretty = date_i18n( 'j. F Y', $event_date);
    echo $event_date_pretty .' : '. $event_name;
    }
    }
    

    hope that help

  • why use flexible content when you like to disable add new, and also like to have all fields published from beginning?

  • i am not sure if frontend form also add the Wrapper-Attribute class, but at normal backend the Wrapper-Attribute class or the ID are added to the container of the ACF Field (at least when you use ACF-Pro)

    look here at the screenshot image
    Wrapper Attribute are the last 3 input fields (all at same row) at each ACF-Field, above close Field. (class is the middle field)

    with help of Wrapper Attribute (class and ID) you should be able to style the backend.
    that means: add, for example “something” to the Wrapper Attribute class, and use that to style the backend (hope/think it works your frontendform too). and use code like from my first post to add class also to normal frontend view.

    maybe you need a bit nested css, because the class is added to the parent container of the field, and not the field itself where you add it.

    i am not sure, but i think you cant access these classes at normal frontend view, and you need to add these classes for normal frontend view manually.

    or you could use the fieldkeys of your ACF Fields directly as your css IDs
    and use that to style the backend.
    for example: #acf-field_508a263b40457
    (of course you need to replace field_508a263b40457 with the id of your field)

    hope that my explains are clear enough, and that they help to solve your problem.

    if you still have problems, post of the relvevant parts that you use codesnippets (and add maybe images, to show what is and what should be)

  • would this work? :

    <?php $facebook_url = get_field('facebook' , 'option');
    if( $facebook_url ): 
    echo '<a target="_blank" class="facebook_icon" href="'.$facebook_url.'"><img src="https://www.facebookbrand.com/img/assets/asset.f.logo.lg.png" alt="facebook-icon"></a>';
    //change src of facebook to your server 
    endif; ?>
  • do you talk about backend, or about frontend?

    at backend there is the wrapper attribute with class/id, use that to do whatever you need

    at frontend you could do whatever you wish:

    $your_field = get_field('your_field');
    echo '<div class="something">'; //whatever you like to wrap around(pre) your field
    echo $your_field; //your field value
    echo '</div>'; //whatever you like to wrap around(after) your field
    
  • could you try if this works:

    $book_type ='';
    	$book_type_field = get_field_object('book_type');
    	$book_type_values = get_field('book_type');
    	$count = count($book_type_values);
    	foreach ($book_type_values as $key => $value) {
    		$book_type .= $book_type_field['choices'][ $value ];
    		if (($count - 1  - $key) >= 1){$book_type .= ', ';}
    	}
    echo $book_type; //do this whenever you wish (this variable should contain all chosen labels, separated by a comma)
    

    or do you get also a error with this code

  • you need to set Return Format to Ymd because only then you can order dates correct.
    and use something like this:

    $get_startdate = get_field('my_startdate'); 
    $start_date = (strtotime($get_startdate));
    //use $get_startdate to order, and $start_date_pretty to output your date
     $start_date_pretty = date_i18n( 'd/m/Y', $start_date );
    echo $start_date_pretty;
    

    hope that help you to get what you wish to try

  • do you talk about backend or frontend?

    i think something like this should work(for frontend):
    outside(before) the values loop define variable
    $total = '0';
    inside the values loop
    $price = get_sub_field('price'); $total = $total + $price;
    outside(after) the values loop
    echo $total;

  • just to get sure:
    you have a flexible field with which layouts?
    if headline and text_content are separate layouts than it is clear why it do it like that. (because it do for each layout echo headline and text, and at each one there is missing the other field)

    if( have_rows('content') ):
    while( have_rows('content') ): the_row();
    if( get_row_layout() == 'layoutname_of_headline' ){ 
    $the_headline = get_sub_field('headline');
    echo '<h1>'.$the_headline.'</h1>';
    }
    if( get_row_layout() == 'layoutname_of_text_content' ){ 
    $the_text_content = get_sub_field('text_content');
    echo '<p>'.$the_text_content.'</p>';
    }
    endwhile; endif;
  • would it make a difference when you use this? :

    <?php if( have_rows('content') ):
    while( have_rows('content') ): the_row();
    $the_headline = get_sub_field('headline');
    $the_text_content = get_sub_field('text_content');
     ?>
    <h1><?php echo $the_headline; ?></h1>
    <p><?php echo $the_text_content; ?></p>
    
    <?php endwhile; ?>
    <?php endif; ?>
  • @bknightly i cant say how to use it with ID,
    but i can show you how to use a size, when you do it with array (3 option beside id and url)

    $items = wp_get_nav_menu_items('menu_name'); //replace menu_name with menu-name, menu-id, menu-slug (menu-location is not valid!)
    foreach((array) $items as $key => $item) {
    	$taxonomy = $item->object;
    	$term_id = $item->object_id;
    	$url = $item->url;
    	$title = $item->title;
    	$image_url= get_field('icoon', $taxonomy._.$term_id); //replace "icoon" with the fieldname you give to the image
    	echo '<li><a href="'.$url.'" title="'.$title.'"><img src="'.$image_url[sizes][large].'" /></a></li>'; //replace large with size you wish
    }
    

    hope that help nevertheless

    just if someone is interested, i use this for build a taxonomy menu with images:

    <?php
    get_header();
    // to build a menu with image and name from a Taxonomy i use this (inside my archive-CPT.php):
    //this values you need to adjust: 
    //my_taxonomy => slug of taxonomy (3x)
    //my_taxonomy_image => name of imagefield at taxonomy page (1x)
    //teaser_thumbnail => image size
    $terms = get_terms("my_taxonomy", array(
        'hide_empty' => 0
    ));
    $count = count($terms);
    if ( $count > 0 ){
        foreach ( $terms as $term ) {
        $permalink = get_term_link( $term->slug , 'my_taxonomy');
        	$output .=  '<div class="taxonomy_menu_item"><a href='.$permalink.' titel="'.$term->name.'">';
            
            $my_taxonomy_teaserimage = get_field('my_taxonomy_image', 'my_taxonomy_'.$term->term_id);
            $size_taxonomy_teaserimage = 'teaser_thumbnail';
    	$taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage ];
    	$width_taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage . '-width' ];
    	$height_taxonomy_teaserimage = $my_taxonomy_teaserimage['sizes'][ $size_taxonomy_teaserimage . '-height' ];
    	
    	$output .=  '<img alt="'. $term->description .'" src="'. $taxonomy_teaserimage .'" width="'.$width_taxonomy_teaserimage.'" height="'.$height_taxonomy_teaserimage.'" />';
    	$output .=   '<h3>'.$term->name.'</h3>';
    	$output .=  '</a></div>';
         }
    }
    echo $output;
    get_footer();
    ?>
Viewing 25 posts - 1 through 25 (of 181 total)