Support

Account

Forum Replies Created

  • you cant have a dynamic solution with ACF shortcodes.

    but as i write before if you create a custom template for that page.
    and use there something like that

    <?php the_content(); ?>
     <?php if ( is_user_logged_in() ) {
    $userid = get_current_user_id();
    get_userdata( $userid );  
    get_field('sms2', 'user_'. $userid );
    }?>

    of course you need to add the post loop arround, and maybe add a user-role filter too. but i hope that info help you to do it on your own

  • difficult to say. because i don’t know/understand what you wish to split and why you do it.
    also i don’t know what breaks, and why it would break.

    without that info i cant say if it is possible or not. all depends on what you wish to do for what reason.

    but primary yes, without `while ( have_rows(‘projects_content’) ) : the_row();
    if( get_row_layout() == ‘full_width_image’ ): `
    you cant use get_sub_field($caption); of your image

    you may can have the loop only one time and use part of it multiple times.
    could be done with the help of own created arrays, but that is complex, and works only in certain cases

  • it depends if you have a post for every user or not.
    if yes, than it may work with this shortcode [acf field="sms2" post_id="user_1"] of course only for user 1

    if you wish to have 1 post and show value depends on user, i think, you need a custom template for that post

  • as far as i understand <?php get_sub_field($caption); ?> for flexible fields works only inside <?php if( get_row_layout() == 'full_width_image' ): ?> and that need to be inside the flexible field while loop

    i don’t see that loop inside your file, and don’t know if you have it or not

  • if you put full code(that you show us) in a separate file and only captions are empty, then problem is somewhere else.
    because you will/should see nothing or everything.

    i assume you have a flexible-field or repeater field, and inside that you have:
    1 image field (image), and 2 text-fields (title and caption)?

    or do you only have 1 image field and try to use caption and title of it? if it is like that, then use:

    $title = $image['title'];
    $alt = $image['alt'];
    $caption = $image['caption'];

    instead of get_sub_field for title and caption

  • what about using this: wp_update_post( $my_post );

    • inside update_value filter?
    • inside save_post action?

    i use them to update post_title or post_content with values that come from get_field

    or the save action: (all you need is a hidden field with name “totalprice“)

    function my_acf_update_totalprice($post_id)
    {
        $total = get_field('price') * get_field('qty');
        $value = $total;
        $field_name = "totalprice";
        update_field($field_name, $value, $post_id);
    }
    add_action('save_post', 'my_acf_update_totalprice');
  • //add title and alias when a person is created
    function my_acf_update_titlevalue( $value, $post_id, $field ) {
    global $post;
    	// vars (title comes from person_name field that is looked for at the filter, after that the alias is generated)	
    	$new_title = $value;
    	$new_slug = sanitize_title( $new_title );
    	// update post with the "new" title and alias (because we may hide them at our custom post)
    	$my_post = array('ID'=> $post_id,'post_title' => $new_title,'post_name' => $new_slug );
    wp_update_post( $my_post );
    return $value;
    }
    add_filter('acf/update_value/name=person_name', 'my_acf_update_titlevalue', 10, 3);

    try something like above at your plugin: change person_name to your acf field
    hope that help and work for you

  • use a hidden field and update value of it based on the other values.

    may use that: https://github.com/folbert/acf-hidden (out of this thread)

    than use update_field or update_value to save it into DB

  • if you have multiple layouts where you use different pieces of the whole file (like gallery)
    and wish to edit that pieces not at every single layout then you can maybe put code into a single php file. (galleyloop.php)

    and call it there where you need it like that: include_once ('galleyloop.php');
    if include_once dont work try include

    of course that works only when you call it not outside the loop. but maybe the reason you take it outside the loop was to reuse it at different layouts

  • sorry. without basic php knowledge ACF is useless for you. (imho)
    because every frontend view need to be created at your own. (coded php/mysql/js/wp)

    if someone code that for you. content could be filled easy with ACF.
    but if you have to do it on your own, i assume it would be easier to search something else than ACF that no coding need. (visual composer: could maybe the tool that you search)

  • hope i understand you right. (i had done core search ability by a workaround)
    if you dont use the normal content field of WP, then you could try something like that:

    function my_acf_update_text($post_id) {
    		
    if( have_rows('my_custominhalt') ):
    
         // loop through the rows of data
    	while ( have_rows('my_custominhalt') ) : the_row();
          
    	        $my_search="";
    	        if( get_row_layout() == 'text-block' ){
    	        $my_subtitle = get_sub_field('my_subtitle');        
    	        $my_content = get_sub_field('my_text_content');
    	        $my_search = '<h3>'.$my_subtitle.'</h3><p>'.$my_content.'</p>';
    	        }
    	             
    	        if( get_row_layout() == 'text-image-block' ){
    	        $my_subtitle = get_sub_field('my_subtitle');        
    	        $my_content = get_sub_field('my_imagetext');
    	        $my_search = '<h3>'.$my_subtitle.'</h3><p>'.$my_content.'</p>';       
    		}
    		$my_search_full = $my_search_full.' '.$my_search;
    	endwhile; 
    endif;
    	
    	// update post with the post_content created from 
    	$my_post = array('ID'=> $post_id,'post_content' => $my_search_full);
    
    remove_action('save_post', 'my_acf_update_text');
    wp_update_post( $my_post );
    add_action('save_post', 'my_acf_update_text');
    
    }
    add_action('save_post', 'my_acf_update_text');

    place it into your plugin, or functions.php
    what it does : it create a action that loop through all flexible fields with text, and save them to post_content. thanks to that i am able to search content by core function.

    hope that help you too (of course you need to adjust it to fit your needs)
    be careful, it overwrite anything inside post_content(core-wysiwyg of WP)
    you also need to re-save every post before it works, because only after save content is inserted into post_content

    if you need core-wysiwyg, then create a additional field and save the loop into that field. basically it would be easier to search only inside a single field instead of a repeater/flexible field

  • i am glad that i was able to help you.
    but i cant read/see your reply, because it is marked as private.

  • i think it is possible when you “adapt” this dynamically-populate-a-select-fields-choices and combine it with your function to scan the directories.

    for first dropdown do something like that:

    function acf_load_color_field_choices( $field ) {
        // reset choices
        $field['choices'] = array();
    //fill here your array into the variable $choices
    $choices = php glob() function that you have;
    //
        // loop through array and add to field 'choices'
        if( is_array($choices) ) {
            foreach( $choices as $choice ) {
                $field['choices'][ $choice ] = $choice;
            }
        }
        // return the field
        return $field;
    }
    add_filter('acf/load_field/name=color', 'acf_load_color_field_choices');

    for second dropdown, you need to get the value of first dropdown and do nearly same again.
    hope i have understand you right, and this answer help. or at least lead you to the right direction

  • if you talk about frontend, than place your code inside a if-loop like that:

    <?php 
    $custom_format = get_field('custom_format');
    if($custom_format == "option2"){
     if( get_field ('custom_infotext') ) : ?>;
      <p class="custominfo">
       <?php the_field('custom_infotext'); ?>
      </p>
     <?php endif; 
    }?>

    replace custom_format with your fieldname, and option2 with the value of option2

  • you need to do something like this:
    the key is = to loop first through all post, save marker/values into an array (without echo something), output one single map, and output the markers from saved array

    <?php 
    $the_query_map = new WP_Query( array( 'post_type' => 'event', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    
    if($the_query_map->have_posts()) :
    while($the_query_map->have_posts()):
    $the_query_map->the_post();
    $the_ID = get_the_ID();
    $get_google_map = get_field('event_map', $value);
    
    $output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'"></div>';
    
    endwhile; endif;
    wp_reset_postdata();
    
    ?><div class="acf-map"><?php
    foreach( $output_map as $key => $map_marker ):
    	echo $map_marker['map'];
    	endforeach;
    	?>
    </div>

    you need to adapt my code that it fit your needs, but i hope with that help you can do it at your own.

  • try to replace this line:
    <?php while(has_sub_field('index_banner_carrossel', 'option')): ?>
    with this
    <?php while( have_rows('index_banner_carrossel', 'option') ): the_row(); ?>

  • have you same problem (shortcode that did not work) with Contact Form 7 or some other plugin that use shortcode?
    because i cant confirm any problem with ACF and shortcode. (not inside wysiwyg, nor inside textarea or textbox)

    if you have same problem with Contact Form 7 too, then problem is maybe a filter, your template, or an other plugin that you use.

    if Contact Form 7 has not the same problem then your slider-plugin/shortcode is the problem.

    or maybe this help:
    $slider = get_field('page_slider',$page->ID, false);

  • try this

    drop this lines:

    $temp = $wp_query; 
    $wp_query = null; $wp_query = $temp;

    and use this to reset query
    wp_reset_query();

  • you need to add some js and do some code changes that it fit.
    depends on selected js that would normally be div or ul/li (or a combination of it)

    Basicly it would be something like

    wp_register_script ...
    wp_enqueue_script ...
    <div class="slider_container">
        <ul>
            <?php foreach( $slides as $slide): ?>
            <li>
                code to load img permalink text from slide
            </li>
            <?php endforeach; ?>
        </ul>
    </div>

    maybe not what you like to hear, nevertheless i hope that this info help you to solve your problem

  • what is the value of form_perso field?

    $formPerso = get_field('form_perso');
    echo '<pre>';
    echo htmlspecialchars(print_r($formPerso,true));
    echo '</pre>';

    why you didnt try out ACF CF7 Field Plugin?
    create a ACF CF7 Field with name selected_form and show it at frontend:

    <?php if( get_field('selected_form') ):
         the_field('selected_form');
    endif; ?>

    maybe this solve problem too:

    $formPerso = get_field('form_perso', false, false);
    do_shortcode($formPerso);
  • you can try something like this:

    /**
     * Exclude current and static post/page from relationship field results
     */
    
    // 1. Add the name=[NAME_OF_RELATIONSHIP_FIELD].
    add_filter('acf/fields/relationship/query/name=my_relationship_field', 'exclude_id', 10, 3);
    
    // 2. Add the $field and $post arguments.
    function exclude_id ( $args, $field, $post ) {
    
        //3. $post argument passed in from the query hook is the $post->ID.
        $args['post__not_in'] = array( $post, 1994, 1999, 1979, 4201, 1989 );
        //should exclude post you edit, and posts with id 1994, 1999, 1979, 4201, 1989
        return $args;
    }
  • you may can do that with a workaround.
    if you can add a taxonomy (default active, for new posts)
    add that to all existing posts that should shown at relationship field.

    now you can use the filter taxonomy inside the relationship field (set it to this new created taxonomy)
    with that only post that have this taxonomy shows up.

    hope that help to solve your problem

  • i think it is possible.
    you can link 2 posts with help of relationship fields.

    based on that you have a post for each ship, and apost for each destination:
    with help of relationship-field you can show data from linked destination at ship site.
    and/or data from linked ship site at destination site.
    (but as far as i know only at fronend, not at backend)

    maybe you need an additonal post prices, with 2 relationship fields (one for ships, one for destinations)

    hope that help you to find a solution that fits your needs

  • I would also like to know how to edit the wysiwyg, but not only the toolbar!

    what i know is:
    because acf not use the default tinymce of wp-core (or at least use a own init method) some solutions that work with core didnt work with acf-wysiwyg fields.

    Additional/similar Topics to this thread (with no answer!)
    http://support.advancedcustomfields.com/forums/topic/wysiwyg-editor-acf-is-missing-general-wp-editor-functionality/
    http://support.advancedcustomfields.com/forums/topic/acf-pro-wysiwyg-not-getting-changed-default-settings/

  • if you add this before the li tag:

    <?php
    echo '<pre>';
    echo htmlspecialchars(print_r($image,true));
    echo '</pre>';
    ?>

    you will see the sizes that are defined. i assume full is not one of them. 😉

    you can add additional sizes with plugin or inside function.php
    add_image_size( 'myfullsize', '4000', '3000', false );

    but i assume you just need to change a line of your code.
    change it to this:
    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />

Viewing 25 posts - 151 through 175 (of 181 total)