Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @scheurta

    ah, yeah! ok, that’s exactly it. Somehow I thought because the custom post types are ‘capability_type’ => ‘page’, ‘hierarchical’ => true I’d find them under pages. I would have never looked under ‘Post is equal to’, thanks!

  • Untested but here’s something to get you started:

    $post_objects = get_field( 'testimonials_related' );
    
    if ( $post_objects ) {
    	// your normal stuff here..
    } else {
    	// no post objects found, query the post type for 4 random posts
    	// you should cache this query with either the object cache or transients api
    	// http://wordpress.stackexchange.com/questions/183698/way-to-cache-a-query-for-24-hrs
    	$current_post_id = get_the_id();
    	$testimonials = new WP_Query(
    		'post_type' => 'testimonials',
    		'post_status' => 'publish',
    		'posts_per_page' => 4,
    		'orderby' => 'rand',
    		'post__not_in' => array( $current_post_id ) // exclude the current post
    	);
    	
    	if ( $testimonials->have_posts() ) {
    		while ( $testimonials->have_posts() ) {
    			$testimonials->the_post();
    			// display the posts...
    		}
    		wp_reset_postdata();
    	}
    }
  • Hi @frances,

    If i’m understanding correctly, you want to display the fieldgroup under a specific post / custom post type?

    The location rule you’re looking for is the “Post is equal to” rule. That will list all post of your custom post types and the built in Post post type.

  • Hello the question was updated:
    http://wordpress.stackexchange.com/questions/184045/query-post-from-field-with-multiple-values-acf-advanced-custom-fields

    Is it impossible if I only use text fields?
    because there is a chance that user is going to input new hobbies and sports. If I use checkbox, What im gonna do? Do you mean that Whatever I type in the custom fields inside the post, It will going to populate the checkbox field on the “Page query template”? Sorry im not really good at php that’s why

  • Hi, I’m still getting this on 5.2.2

    When saving the post it says “Validation failed. 1 required field below is empty”.

    The only thing I need to do to fix it is checking the checkbox that makes the hidden inputs visible. I’ll then see the error message next to the field. Then I uncheck and hit save again and it will work.

    The field in question is a Repeater field which has conditional logic to display if the checkbox is checked (“Stablet”=checkbox, see attachment).

  • Hi @slash_1968

    Hmm… May be you could consider using Checkbox field instead of a simple text field and loop through your $value array to generate your meta_query $args dynamically. Then using the code provided here to query the posts: http://www.advancedcustomfields.com/resources/checkbox/

  • Hi @kevin-mamaqi

    The existing custom fields will not be deleted. Try it out. Once created, the new ACF fields will pick up the value of the existing custom fields.

  • Hi Mamaqi,

    Hmm… May be you could try to create new ACF fields with the same name as your existing custom fields.

  • Hi @jonjansma

    Could you have hooked a function to the acf/fields/post_object/query filter?

  • I have the same exact question. I can’t really find a good way of exporting a template for my csv file.

  • Definitely would love to seeing this working!

    Encountering the same issues here with Beaver Builder. Looks like ACF is set to only load the widget fields on the Widget customiser page – anywhere else it just fails. I’ve also tried to go through the code myself to see if there’s anything that can be tweaked/adopted in the custom widget to get this functionality working with either this or Site Origin’s PB but no joy so far.


    @mountainthemes
    you’ve got further than me! – great to see at least the fields coming through. I can confirm the additions you added to your widgets form method are working for me as well in both Site Origins PB + Beaver Builder (see attached). I’ve also +1 on the feature request.

  • This is my matching function. It functions correctly but only on page load. Is anyone able to suggest how to get custom taxonomy terms into the $options array so the function can evaluated on changes to the custom taxonomy.

    function acf_location_rules_match_taxonomyTerm( $match, $rule, $options ){
        // vars
        $taxonomies = get_object_taxonomies( $options['post_type'] );
        $terms = $options['taxonomy'];
        // not AJAX
        if( !$options['ajax'] ){
            // no terms? Load them from the post_id
            if( empty($terms) ){
                if( is_array($taxonomies) ){
                    foreach( $taxonomies as $tax ){
                        $all_terms = get_the_terms( $options['post_id'], $tax );
                        if($all_terms){
                            foreach($all_terms as $all_term){
                                $terms[] = $all_term->term_id;
                            }
                        }
                    }
                }
            }
            if($rule['operator'] == "<==>"){
                $match = false;
                if($terms){
                    $current_terms = get_the_terms($options['post_id'], $rule['value']);
                    if ( $current_terms && ! is_wp_error( $terms ) ) {
                        $current_term_ids = array();
                        foreach ($current_terms as $current_term) {
                            $current_term_ids[] = $current_term->term_id;
                        }
                    }
                    foreach ($current_term_ids as $current_term_id) {
                        if( in_array($current_term_id, $terms) ){
                            $match = true;
                        }
                    }
                }
            }
            else{
                $match = false;
            }
        }
        return $match;
    }
  • I’m having similar issues where repeater fields are not working in a widget. I creates a repeater called logos, and places it in a footer widget. It only contains 3 small logos and all fields have short names.

    It works on all pages, posts, archives etc….

    But then when you do a search, they are missing from the search results page.

    How would I query widget fields directly like you can do posts with get_post_meta()?

    Thanks.

  • I haven’t come close to getting this to work either. ACF is the best for fields, and PB is the best in terms of creating layouts. Building a layout builder using ACF alone, while straightforward, yields an adequate UI at best.

    From what I understand, you can create a field, and then assign it to a particular registered widget. Then when you add that widget to a widget area, or Page Builder, the ACF fields should appear. I find they do in some cases.

    So the workflow for getting ACF and PB to work together would be to register a new widget type for every block element. Icon box, testimonials, etc… Create an ACF field group for each widget type and assign the group to the previously registered widget above.

    In your theme, display the widget content using get_field within the Widget’s callback.

    I would love to see just one working example of this.

  • found this from another post – Worked like a charm for me.

    
    <?php $posts = get_field('featured_space'); if( $posts ): ?>
      <div class="acf-map">
        <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
          <?php setup_postdata($post); ?>
            <?php $space_address = get_field('space_address', $post->ID); ?>
              <div class="marker" data-lat="<?php echo $space_address['lat']; ?>" data-lng="<?php echo $space_address['lng']; ?>">
                <h4><?php the_title();?></h4>
                <p><?php echo $space_address['address']; ?></p>
    					</div><!--/.marker-->
    	  <?php endforeach; ?>
        <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
    	</div><!--/.acf-map-->
    <?php endif; ?>
    
  • From ACF posts.php and api-field-groups.php, this should get you started:

    $posts = get_posts(array(
      'post_type' => 'acf-field-group',
      'posts_per_page' => -1,
      'orderby' => 'menu_order title',
      'order' => 'asc',
      'suppress_filters' => false, // allow WPML to modify the query
      'post_status' => 'publish',
      'update_post_meta_cache' => false
    ));
  • Have you tried forcing it to use the default visual editor in your theme’s functions?

    add_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );

    I run both latest VC and ACF and don’t see this issue.

  • Same problem here… and getting desperate…

    Checked max_input_vars, nesting_levels, input_time… Also changed option_name to 255 chars… Nothing.

    No errors neither in php logs, apache or mysql. No slow queries… I’ve debugged with save_post and acf/save_post and the array is complete in WP debug.log (it includes the not saved fields)… But they do not save to the DB…

    This behavior started after adding a repeater field in a field group. I had a lot of custom posts with custom fields working fine. Then realized I needed one more repeater field and added to the field group… This made the fields stop saving…

    Some magic would be greatly appreciated 🙂

    Latest version of WordPress and ACFPro at this time.

  • The second parameter of the remove_meta_box method takes the post_type. So if your custom post type is “products”, just do remove_meta_box("wpseo_meta", "products", "normal");

    Also, keep in mind that the third parameter is one of “normal”, “advanced”, or “side” and is dependent on where that meta box is situated. Basically, if normal doesn’t work, try advanced. 🙂

  • Maybe this alternate solution is a little bit faster. It simply change the default option of the colorpicker when there are acf fields on the page.

    
    function change_acf_color_picker() {
      // Adds client custom colors to WYSIWYG editor and ACF color picker.
      $client_colors = array(
        "#222222",
        "#8dc4d5",
        "#e1523d",
        "#eeeeee",
        "#323232",
        "#ffffff",
        "#000000"
      );
    
      echo "<script>
      (function($){
        try {
          $.wp.wpColorPicker.prototype.options = {
            palettes: " . json_encode($client_colors) . "
          };
        }
        catch (e) {}
      })(jQuery)
      </script>";
    }
    
    add_action( 'acf/input/admin_head', 'change_acf_color_picker' );
    
  • @toolboxwebdesign, thank you very much again. You solved my question very well!

  • it is possible but you need to rebuild/change your code.
    you need to fill first all rows to variables or a array.
    and use that to echo values. (here i use variables)

    simple it would look like that:

    <?php
    $count = 0;
    $list_employee = '';
    $div_employee = '';
    while ( have_rows('employees') ) : the_row();
    $count++;
    $list_employee .= '<li><a href="#employee-'; //whole code for li (no echo!, nothing outside php, get_field instead of the_field)
    $div_employee .= '<div id="employee-'; //whole code for div (no echo!, nothing outside php, get_field instead of the_field)
     if ($count % 5 == 0) { //each 5 rows echo ul and div
    echo '<div class="tabz"><ul class="employees">';
    echo $list_employee;
    echo '</ul>';
    echo $div_employee;
    echo '</div>';
          $list_employee = '';
          $div_employee = '';
       }
    endwhile;
    if ($list_employee){ //if all rows are done but 1-4 rows left, echo them
    echo '<div class="tabz"><ul class="employees">';
    echo $list_employee;
    echo '</ul>';
    echo $div_employee;
    echo '</div>';}
    ?>

    try to modify your code like above, just the whole one. this should work.
    if not: show whole modified code and what the “error/problem” is.

  • just to get sure. you wish:

    <div class="tabz">
    //ul with 5 rows employees
    //div with 5 rows employees
    </div>
    <div class="tabz">
    //ul with 5 rows employees
    //div with 5 rows employees
    </div>
    ...

    and both (ul and div) use same repeater

  • you need to add the css&js from link you have from documentation
    you need the the full code from : Required CSS & JS
    just customize it when you know what you do

    and full code from : Render a single maker onto a map
    just change location from the code get_field('location'); to the field-name you use

    of course you can add css part to template-css and outsource the js part into a file and use wp_register_script and wp_enqueue_script to include it.

  • I found out that the problem was not because of ACF, it was because of ACF-qTranslate plugin. Check your other ACF Plugins and see if they have the issue.

Viewing 25 results - 16,926 through 16,950 (of 21,332 total)