Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • <?php 
    $count = 0;
    while( have_rows('carousel') ): the_row();
    if ($count == 0) {
    echo '<li data-target="#bs-carousel" data-slide-to="0" class="active"></li>';
    } else {
    echo '<li data-target="#bs-carousel" data-slide-to="'.$count.'"></li>';
    }
    $count++;
    endwihle; ?>

    try something like above.
    and try to adapt it for slide too. (define counter outside of while, check for first counter add there the active. do else, and increase count before endwhile)

  • <?php 
    
    $posts = get_field('relation');
    
    if( $posts ): ?>
    	<div class="acf-map">
    		<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT)?>
    		<?php $location = get_field('spot_lieu', $p->ID);  ?>
    
    			<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>">
    			<h4><?php echo get_the_title( $p->ID ); ?></h4>
    			<p class="address"><?php echo $location['address']; ?></p>
    			<p><?php echo get_the_post_thumbnail($p->ID); ?></p>
    			</div>
    
    		<?php endforeach; ?>	
    	</div>
    	
    	<ul>
    	<?php foreach( $posts as $p ): // variable must NOT be called $post (IMPORTANT) ?>
    	    <li>
    	    	<a href="<?php echo get_permalink( $p->ID ); ?>"><?php echo get_the_title( $p->ID ); ?></a>
    	    	<span><?php the_field('spot_lieu', $p->ID); ?></span>
    	    	 <p><?php echo get_the_post_thumbnail( $p->ID); ?> 
    </p>
    	    </li>
    	<?php endforeach; ?>
    	</ul>
    
    <?php endif; ?>
  • I suspect this happens because your fields inside the tab end up having the same name as the tab itself.

    So, if you name tab Slider and then create Repeater Slider inside it, it will fail, even though Tab’s name or slug is not explicitly available to edit.

    As user you can name your tab with tab at the end, so that automatically created name would have it, later you can change the Title of the tab.

    But it should be fixed by developer by adding some unique suffix or at least “__tab”.

  • I think this is expected behavior. Updating the way the field returns data would require you to update the field in the database by updating the post.

  • i can confirm such problems, but i had to add a even more worse problem created by a “similar” Environment

    i had repeater with 4-5 row before, 2-3 with no value inside url-field.

    after add true/false field and set required like described above
    i add 6th repeater row, because of not filled required field save fail.
    i check/uncheck true/false field and try to save again.
    strangely enough that works! but this bug happens:
    inside url field a value was filled that came from a other row. but not only inside the new row, it was filled inside every empty hidden url field.

    (fortunately i dont need such a setting at productive state, but that need of course a fix as soon as possible)

    If someone had the time he can test: if it happens with all conditional field inside repeater (like checkbox, radio-button, select, …) and if it happens to other fields than url too

  • Yup, ACF V5 PRO and ACF qTranslate wont play nice (at least with qTranslate Plus). Had to go back to ACF v4 so everything works good.

    Won’t work: WP 4.1.1 + ACF PRO 5.1.7.1 + Advanced Custom Fields: qTranslate 1.4 + qTranslate Plus 2.7.2 inc. Patches
    Works: WP 4.1.1 + ACF 4.4.0 + Advanced Custom Fields: qTranslate 1.4 + qTranslate Plus 2.7.2 inc. Patches

    It looks like “ACF5PRO” is not recognising the new fields created by “Advanced Custom Fields: qTranslate 1.4”, so when you assign them and save your custom fields, they appear as regular ones. Then the editor will break apart silently.

    Please let me know if this gets fixed, since ACF5PRO was playing great.

    Thanks!

  • Solved it by modifying the plugin to enqueue only on that certain page.

  • Ok I was wrong – it IS a plugin that stops the MAP field and other JS from working.
    In fact, ANY other Map plugin conflicts with ACF.

    Either the map created from the plugin won’t render, or the plugin breaks ACF’s JS.

    The Plugin (WP GPX Maps) loads a script in its plugin file correctly with wp_enqueue_script( 'googlemaps', '//maps.googleapis.com/maps/api/js?sensor=false', null, null);
    which causes the conflict.

    Any attempt to load this JS only on certain pages etc fails (function.php with add_action etc).

    I am not sure wether this is a problem with the plugin or with ACF, any help is appreciated.

  • hi, i think the main part should look like this

    <?php $carousel = get_field('carousel');
            if($carousel):
            while( have_rows('carousel') ): the_row();
    
    	$slider_image	= ""; 
    	$slide_headline	= ""; 
    	$sub_headline	= ""; 
    	$button_url	= ""; 
    	$button_text	= ""; 
    
    	$slider_image	 = get_sub_field('slider_image');
    	$slide_headline	 = get_sub_field('slide_headline');
    	$sub_headline	 = get_sub_field('sub_headline');
    	$button_url	 = get_sub_field('button_url');
    	$button_text	 = get_sub_field('button_text');
    ?>
        <div class="item slides">
          <div class="cslide" style="background: url(<?php echo $slider_image; ?>)"></div>
          <div class="hero">
            <hgroup>
                <h1><?php echo $slide_headline; ?></h1>        
                <h3><?php echo $sub_headline; ?></h3>
            </hgroup>
            <a href="<?php echo $button_url; ?>"><button class="btn btn-hero btn-lg" role="button"><?php echo $button_text; ?></button></a>
          </div>
        </div>
    <?php endwhile; endif;?>

    hope that help.
    depends on what is required, and what your image output is, you may need to adjust your code. here a sample how to make a optional field and get image when use array

    <php? if($my_teaserimage){
            echo '<div class="teaserimage"><img src="'. $my_teaserimage['url'] .'" /></div>';
            } ?>
  • ok thanks so would you mean this code should show
    only EVENT where month=current month ?
    thnaks

    $today = date("d/m/Y");
    
    $themonth=substr($today, 3,2);
     
    $args = array (
        'post_type'       => 'EVENT',
         'meta_key'        => 'dates_%_date_EVENT',
        'meta_value'      => '[0-9]{4}' . $themonth . '[0-9]{2}',
        'meta_compare'    => 'REGEXP',
    );
  • This reply has been marked as private.
  • Hi @Pipoulito

    Sorry, but I don’t understand your last question.

    The % is a wildcard and will match any string which allows it to work with the repeater field incremental numbers for sub field keys

  • I also have the same question: I have 3 fields and one is a True-False field. Based on your selection of True or False how can I show the other 2 fields? Please advise

  • Having the same issue. Version 5.1.9.1.

    I can confirm that it’s related to conditionally hidden form fields, as setting the “Required” option to false allows the submission to proceed.

    The example screenshot shows a field titled “Network Name” that is shown when “Network” has the value of “Other Network”.

  • Ohhhhh guys! Thank you)

    Can you add prefix, like ACF – Field Group Name.
    So it will be easier for a simple user

    IMG

  • We also are experiencing this issue after the last update (v5.1.9.1.) Our setup:

    3 fields

    Field 1. Radio button field set to required with two choices (A,B)

    Field 2. Text button field set to required with a conditional to show if radio button choice (field 1) = A

    Field 3. Text button field set to required with a conditional to show if radio button choice (field 1) = B

    Before the last update, this worked fine. If field 1 was set to A, field 2 would show and field 3’s required option was ignored. With the new update, both field 2 and field 3’s required option seems to be checked regardless of what field 1 is set to (e.g., if field 1 = A, only field 2 is shown but field 3’s required validation is also run.)

    Hope this helps,

    Rob

  • Wouldn’t that mean hard coding these field keys into my code?

    In the meantime I ended up querying the database like this:

    
    function get_field_label( $field, $value ) {
        global $wpdb;
    
        $label = '';
        $field = $wpdb->get_col( $wpdb->prepare( "
            SELECT post_content FROM {$wpdb->posts}
            WHERE post_excerpt = '%s' 
            AND post_type = 'acf-field'
        ", $field ) );
    
        if( $field ) {
            $options = unserialize( $field[0] );
            $choices = $options['choices'];
            $label = $choices[$value];
        }
    
        return $label;   
    }
    
  • get_field_object requires the field key if you are not referencing a saved value. The field key looks something like: field_53beaa2f69615

    In the Edit Field Group screen:
    Screen Options (window shade) > Show Field Key: Yes

    One you have it:

    $field = get_field_object($field_key);
    echo $field['choices']['fr'];

    foreach( $field['choices'] as $name => $label ) { ... }

    For more: http://www.advancedcustomfields.com/resources/get_field_object/

  • as far as i understand:
    conditionally hiding save only visible field. that why it allows you to skip some “may required” fields. it never does or should delete saved values by switch condition.
    if you delete something and switch. delete is not saved because everything is only saved when it is visible and you click save.

    to be fair/true: 😉 your main problem is not hidden or not hidden, you try to delete a required field. and a required field is like a radio-button with 1 value. you cant deselect it once set. this is something that is not possible without additional coding or a workaround.

    one way to remove a value from DB set by required-field is:
    set it to not required, delete value, and save. after that set it back to required.
    but that is not practical 😉 and nothing a customer should be able to do.

    what (may) should work too is: duplicate image-field (same field-name!)
    show it at color but set it as not required. (set conditionals same as color)
    let original required at image conditional.
    if you switch from image to color: required image set by image is shown as not required at color. image can be deleted there because it is not required.
    with that it can be saved, but customer had to delete it manually.

    it may could work with a update_value filter and wp_update_post too

    but my advise: solve problem at save_post action or with flexible field

  • I think it might require an extra array. Try debugging with this code. Does the after print look right?

    add_filter( 'acf/fields/wysiwyg/toolbars', 'my_toolbars' );
    
    function my_toolbars( $toolbars )
    {
    	// dev
    	echo "<pre style=\"padding:10px;border:1px solid red;background-color:#fff;color:#111;font-family:Courier;\">";
    	print_r( "\n\n"."before we change stuff ▼\n" ); print_r( $toolbars['Basic'] );
    	echo "</pre>";
    
    	array_unshift( $toolbars['Basic'], 'forecolor' );
    
    	// dev
    	echo "<pre style=\"padding:10px;border:1px solid red;background-color:#fff;color:#111;font-family:Courier;\">";
    	print_r( "\n\n"."after we change stuff ▼\n" ); print_r( $toolbars['Basic'] );
    	echo "</pre>";
    
    	return $toolbars;
    }
  • You can add this to your functions.php to restrict shown media to the items owned by the current user:

    add_action('pre_get_posts','my_restrict_media_library');
    function my_restrict_media_library( $wp_query_obj ) {
    
    global $current_user, $pagenow;
    
    if( !is_a( $current_user, 'WP_User') )
    
    return;
    
    if( 'admin-ajax.php' != $pagenow || $_REQUEST['action'] != 'query-attachments' )
    
    return;
    
    if( !current_user_can('edit_files') )
    
    $wp_query_obj->set('author', $current_user->ID );
    
    return;
    
    }
    
  • using @relish27 suggestion
    <?php the_field('field_name', $post_object->ID); ?>
    instead of
    wp_reset_post_data();
    saved my life.

    I was not able to get
    wp_reset_post_data(); to without a main loop, just with custom queries.

  • I did something very similar recently. The code below basically queries the field ‘events’ for a list of events the user is associated with then adds the list to an array to use with the ‘include’ argument in the wp_query. Hope this snippet points you in the right direction

    function my_post_object_results_for_specific_user( $args, $field, $post )
    {
    
        global $current_user, $wp_roles; get_currentuserinfo();
    
        $user_id = $current_user->ID;
    
        $events = get_field('events', 'user_'.$user_id );
    
        $event_info = array();
    
            foreach( $events as $event){
    
                $event_info[] = $event->ID;
    
            }
    
        $args['include'] = $event_info;
    
        return $args;
    }
  • The above code worked for me with one tweak. Do not put single quotes around the $rowsarray variable.

    $rowsarray = get_field('financialreports');
    $rows = array_reverse($rowsarray);
    if($rows)
  • 5.1.9.1 update fixed the broken strings for me (Dutch language).
    Thanks for the quick update.
    Plugin works fine again now.

Viewing 25 results - 17,151 through 17,175 (of 21,345 total)