Support

Account

Forum Replies Created

  • i tend to use a neutral prefix for all fields created by me & followed by the slug of cpt as second prefix.
    would be for example: myacf_book_author, ...

    why?
    with that i can be 99% sure that i dont conflict with other fields.
    i am also able to reuse the “fields/code” for an other customer, without the need to rewrite anything.

  • theoretical it could both (front and back-end) could be solved by adding a radio button before the image & textfield with left and right. and then add a logical condition based on this field. add twice the text and image field with same names, once ordered image first once text first.

    • radio button: with values left and right
    • imagefield with condition left
    • textfield with condition left
    • textfield with condition right
    • imagefield with condition right

    at php use value of radio button to show image at left or right

    $my_image_position = get_sub_field('my_image_position');
    if($my_image_position == "left"){the_sub_field('my_image'); the_sub_field('my_text');}
    if($my_image_position == "right"){the_sub_field('my_text'); the_sub_field('my_image');}
  • would it make a difference if you use this array instead of the track_url direct?

    $track = get_sub_field('track_url'); 
    //if you use data-array instead of data-url at file return
    //$track_url = get_sub_field('track_url') ;
    //$track = $track_url['url'];
    
        $attr = array(
            'src'      => $track ,
            'loop'     => '',
            'autoplay' => '',
            'preload' => 'none'
            );
       echo wp_audio_shortcode( $attr );
  • do you need the label or only the value? i think $value is enough
    echo wp_get_attachment_image( $row['image'], $value );

    if that didnt work:
    did it work when you define size directly? just to get sure that your wp_get_attachment_image is correct.

  • get custom image size from option page is something that (should) work 😉
    why? => because i had a site where i use that 🙂 (crated a few weeks ago)

    but as john say try to recreate the custom size. (with help of plugin, or replace image with a new uploaded and look if that works)

    if that not works, you may add the add_image_size at a place where option page is not able to access it, or something else is strange

  • sorry my mistake 😉

    i had replaced code with a markup that i use and works. till i found what was wrong with my code that i originally post

  • this is a markup that works for me
    (that has the content-blocks inside sub-flexible fields.

    flexible field my_customcontent_width with layouts:
    my_customcontent_full and my_customcontent_half_half

    flexible field my_customcontent inside my_customcontent_full
    with layout text_block

    flexible field my_customcontent_lefthalf inside my_customcontent_half_half
    with layout text_block
    flexible field my_customcontent_righthalf inside my_customcontent_half_half
    with layout text_block
    )

     <?   
    if( have_rows('my_customcontent_width')):
    while ( have_rows('my_customcontent_width') ) : the_row();
    if( get_row_layout() == 'my_customcontent_full' ){	
    	if( have_rows('my_customcontent') ):
    		echo '<div class="full">';
    		// loop through the rows of data
    		while ( have_rows('my_customcontent') ) : the_row();
    			
    			//text block start
    				if( get_row_layout() == 'text_block' ){
    				$text = get_sub_field('my_text');
    				echo $text;
    				}
    			//text block end
    			
    		endwhile;
    		echo '</div>';
    	endif;
    
    }
     
    	if( get_row_layout() == 'my_customcontent_half_half' ){
    	echo '<div class="lefthalf">';	
    		while ( have_rows('my_customcontent_lefthalf') ) : the_row();
    		
    			//text block start
    				if( get_row_layout() == 'text_block' ){
    				$text = get_sub_field('my_text');
    				echo $text;
    				}
    			//text block end	
    			
    		endwhile;
    	echo '</div>';
    
    	echo '<div class="righthalf">';	
    		while ( have_rows('my_customcontent_righthalf') ) : the_row();
    			
    			//text block start
    				if( get_row_layout() == 'text_block' ){
    				$text = get_sub_field('my_text');
    				echo $text;
    				}
    			//text block end
    			
    		endwhile;
    	echo '</div>';		
    	}
    endwhile; endif;
    ?>

    but why use a flexible field with just a single layout inside?

  • it is possible to use a non-standard image size.
    as far i can see you use the correct variables.

    $image = get_field('your_image_field');
    	$size = 'name_of_size';
    	$url = $image['sizes'][ $size ];
    	$width = $image['sizes'][ $size . '-width' ];
    	$height = $image['sizes'][ $size . '-height' ];

    just to get sure that your preferred size exist, what is inside your image variable?:

    $image = get_field('your_image_field');
    echo '<pre>';
    echo htmlspecialchars(print_r($image,true));
    echo '</pre>';	
  • fine 🙂 then you can should use my code.

    hmm, dont know if it is possible to add it with plugin, because i dont know if this is true, when used with plugin:
    This function must be used before the action admin_menu (priority 99) as this is when the options pages are added to WordPress.

    just for testing, could you try to add it with functions.php and look if it works then

    maybe it would also work if you wrap that function inside your plugin with that code: to init it before admin_menu is created

    add_action('init', 'add_my_options_pages');
    function add_my_options_pages() {
        // put code from above in this function
    }
  • as far as i know :
    get_the_excerpt has no params for ID,
    but you may could try direct output the excerpt via $post_object echo $post_object->post_excerpt;
    if that works as i expect, than you get what you wish.

  • it depends on which ACF Version you use:

    • acf_add_options_page => ACF 5
    • acf_add_options_sub_page => ACF 4 and Option-Page Add-on

    Edit: had a missing } at my previous posted code, it is now updated.

    where did you try to add the option page?
    have you try to add it as first function inside your functions.php ?

  • if you would like to add option page as a submenu of a custom posttype than use of that custom posttype as parent_slug

    
    if(function_exists(acf_add_options_page))
    {
    acf_add_options_page(array(
    'page_title' 	=> 'Emplacements de diffusion',
    'menu_title' 	=> 'Emplacements de diffusion',
    'menu_slug' 	=> 'options_emplacements',
    'capability' 	=> 'edit_posts', 
    'parent_slug'	=> 'edit.php?post_type=YOURCUSTOMPOSTTYPENAME',
    'position'	=> false,
    'icon_url' 	=> 'dashicons-images-alt2',
    'redirect'	=> false,
    ));
    }
    

    replace YOURCUSTOMPOSTTYPENAME with your customposttype

    hope that is what you wish. else i misunderstood what you would like to do.

    to show acf fields at this site:
    set position rules to => show when options-site is equal to “Emplacements de diffusion”

    to show value at fronpage use <?php the_field('my_acf_field_at_this_optionpage', 'option'); ?>

  • i assume you use the newest ACF & WordPress Versions. true?

    for me it looks like:
    your template or an additional plugin or language make problems/conflict with ACF.
    if possible => try with default template (and/or) with only ACF plugin active.

    and post results.

    if we could find out what cause the problem than we could try to fix it

  • the most useful way (imho) would be: fill values into variables and echo than when needed.

    <?php
    if( have_rows('best_braai_buys',$page_id) ): 
    $i = 0;
    $before_best_braai_buys = '<ul class="group">';
    $after_best_braai_buys = '</ul>';
    $first10_best_braai_buys = ''; //variable for first 10products
    $morethan10_best_braai_buys = ''; //variable for rest of products
    			    
    	while( have_rows('best_braai_buys',$page_id) ): the_row();
    	$i++;
    	$bbb_product_image = '';
    	$bbb_product_description = '';
    	$bbb_product_image = get_sub_field('product_image');
    	$bbb_product_description = get_sub_field('product_description');
    		if( $i > 10 ) {
    			$morethan10_best_braai_buys .=  '<li class=" list-'.$i.'">';
    			$morethan10_best_braai_buys .= '<img src="'.$bbb_product_image.'" alt="'.$bbb_product_description.'" />';
    // adapt/extend with rest of your values ... important => no echo or nonphpcode
    
    			$morethan10_best_braai_buys .= '</li>';
    		} else {
    			$first10_best_braai_buys .=  '<li class=" list-'.$i.'">';
    			$first10_best_braai_buys .= '<img src="'.$bbb_product_image.'" alt="'.$bbb_product_description.'" />';
    // adapt/extend with rest of your values ... important => no echo or nonphpcode
    
    			$first10_best_braai_buys .= '</li>';
    			}
    	endwhile; 
    endif;
    
    //now you can echo everything you like with something between
    
    //first 10 products
    echo $before_best_braai_buys;
    echo $first10_best_braai_buys;
    echo $after_best_braai_buys;
    
    //whatever you wish
    echo $somethingbetween;
    
    //rest of products
    echo $before_best_braai_buys;
    echo $morethan10_best_braai_buys;
    echo $after_best_braai_buys;
    
    ?>
  • just to understand correct:

    you talk about frontend output?

    goal is: to have a select-box that contains product quantity, and if you select one, then you wish that at a different place the value of price is displayed?

    i assume for that you need javascript.

    try something like that

    //html build with your repeater values (get quantity and price)
    <select id="quantity" name="quantity" required>
        <option name="quantity" value="1" data-price="5 Bucks">1</option>
        <option name="quantity" value="5" data-price="25 Bucks">5</option>
        <option name="quantity" value="10" data-price="50 Bucks">10</option>
        <option name="quantity" value="$quantity" data-price="$price">$quantity</option>
    </select>
    <span id="price-text"></span>
    
    ----
    
    //javascript (jQuery needed)
    <script type="text/javascript">
    $(document).ready(function () {
    $("#quantity").change(function() {
         $('#price-text').text($('option:selected').attr('price-example'));
    }).change();
    });
    </script>
  • just to understand:

    • you had a flexible field with 15 layouts.
    • at page/article/cp you show that flexible field.
    • you/user can now select one or more of this flexible fields.

    and all that you wish is, when you didnt select/add the neck: you dont want to show neck?

    that is what flexible field normally does. (add optional content-blocks, and show them only if needed. with that you can have required fields like a keyvisual a with title, but only when you add keyvisual-block)

    what it does not do is: to look if a layout is already choosen 1 or more times, and if not display a alternate content.
    if you really need that you need to set a variable inside the get_row_layout loop. also you had to put the values into a variable first. after all layout you check each variable and check if it is filled or not & set alternates

    try if you can adapt this code

    <?php
    //define variables 
    $head= '';
    $shoulder ='';
    $neck ='';
    //check for layouts and the values inside
    if( have_rows('attach_files_multiple') ): while ( have_rows('attach_files_multiple') ) : the_row(); 
    
    if( get_row_layout() == 'neck' ) : 
    $neck .= 'all about neck';
    endif;
    if( get_row_layout() == 'shoulder' ) : 
    $shoulder .= 'all about shoulder';
    endif;
    if( get_row_layout() == 'head' ) : 
    $head .= 'all about head';
    endif;
    
    endwhile; endif;
    
    //check for filled values and build layout or the alternates
    if ($head) {
    echo $head;
    } else {
    echo 'no head was chosen ';
    }
    if ($shoulder) {
    echo $shoulder;
    } else {
    echo 'no shoulder was chosen ';
    }
    if ($neck) {
    echo $neck;
    } else {
    echo 'no neck was chosen ';
    }
     ?>
    

    why do you work with flexible fields when you replace anyway everything not filled with a default value?

  • you work with flexible fields, they can be repeated multiple times and with a own order. normally it doesn’t make sense to add a non-existing layout (if it is even possible)
    what you do with your code is to display for each flexible layout that is not neck to display the alternate content.

    if you try to display the overlay when image or file is not filled out (but neck flexible field is chosen than you had to do the if/else loop inside neck)

    something like this

    <!-- Image Start -->
    	<?php $image = get_sub_field('preview_prop_neck');
    	if( !empty($image) ): ?>
    		<img class="media-object" width="100px" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
    	<?php else: ?>
    		<img class="media-object" width="100px" src="<?php bloginfo('template_directory'); ?>/images/pdo.png">
    	<?php endif; ?>
    <!-- Image End -->
  • Sorry für die späte antwort:
    bin ziemlich stark mit Arbeit ausgelastet, daher fehlt mir auch die zeit genauer auf dein Problem einzugehen.

    Die Hauptfrage ist: was passiert wenn 2.2.6 ausgewält ist?
    solange es nur auswirkungen auf 2.2.x hat ist es nicht sehr schwer.
    wenn es jedoch auswirkungen auf ausgaben im repeater darüber hat wird es kompliziert.

    because you use a checkbox inside a repeater it use sub_field.
    use this code inside your 2.2 repeater loop:

    //multi option checkbox
    if( in_array( 'fonts', get_sub_field('abteilung') ) )
    {
        //... 
    echo "fonts is checked";
    }
    //single option checkbox
    if(get_sub_field('abteilung') == 'fonts')
    {
        //... 
    echo "fonts is checked";
    }

    that should work and i hope that it help you to build what you like

    je nach dem was du genau vorhast, wäre es evtl. sinvoller das ganze anders aufzubauen. um das zu beurteilen fehlt mir jedoch die zeit (zudem wären zusätliche bzw. genauere angaben nötig)

  • what code do you use to display the gallery? and what is your gallery-fieldname?
    gallery is an array, that means you need a foreach loop like this to show the images inside that array:

    <?php 
    
    $images = get_field('gallery');
    
    if( $images ): ?>
        <ul>
            <?php foreach( $images as $image ): ?>
                <li>
                    <a href="<?php echo $image['url']; ?>">
                         <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                    </a>
                    <p><?php echo $image['caption']; ?></p>
                </li>
            <?php endforeach; ?>
        </ul>
    <?php endif; ?>
  • This reply has been marked as private.
  • Thanks @elliot this lead me to the solution.

    i can share now this code:

    function my_acf_input_admin_footer() {
    ?>
    <script type="text/javascript">
    acf.add_filter('wysiwyg_tinymce_settings', function( mceInit, id ){
    	
    	// do something to mceInit
    	mceInit.setup = function( ed ){
    	ed.on('init', function () {
             // Note these lists may not be complete & that other tinymce plugins can add their own shortcuts anyway.
                    var ctrls = [ 'u', '1', '2', '3', '4', '5', '6', '7', '8', '9', 's', 'k', 'Alt+F', 'P' ];
                    var modKeys = [ 'c', 'r', 'l', 'j', 'q', 'u', 'o', 'n', 's', 'm', 'z', 't', 'd', 'h', 'o', 'x', 'a', 'w', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
                    // Overwrite shortcuts with no-op function. Key sequences will still be captured.
                    for (var i = 0; i < ctrls.length; i++ ) {
                        //this.addShortcut('ctrl+' + ctrls[i], '', function () {}); //use if tinyMCE <=4.1.7
                        this.addShortcut('Meta+' + ctrls[i], '', function () {});
                    }
                    for (var i = 0; i < modKeys.length; i++ ) {
                        //this.addShortcut('alt+shift+' + modKeys[i], '', function () {});//use if tinyMCE <=4.1.7
                        this.addShortcut('access+' + modKeys[i], '', function () {});
                    }
        });
    	};
    	// return
    	return mceInit;
    			
    });
    </script>
    <?php
    }
    
    add_action('acf/input/admin_footer', 'my_acf_input_admin_footer');

    can be inserted into function.php or a own plugin and should work. and provide the disable of tinymce shortcuts. (at my example it removes: headings, underline, and more. bold and italic shortcuts would still work)

    I will update this post with the other options that wish to use. as soon i tested it

    EDIT:
    TinyMCE <= 4.1.7, and >= 4.1.8 use different code

  • probably it is because:
    event_dates_0_start_date AND event_dates_1_end_date accomplish the start before testdate and end after testdate.

  • i cant see private posts/replys.
    would it make a difference if you change query (add relation line)?

    'meta_query' => array(
    		'relation' => 'OR',
    array(

    and i begin to not understand what dates you like to show & if you have one or more input field or if you use today to check if date should be displayed or not

Viewing 25 posts - 26 through 50 (of 181 total)