Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @advancedcustomfields@swell.nl

    This is a limitation of the WP_Query args.
    If you were to add the status to the meta_query array, then it too would be treated as an ‘OR’.

    It seems that you can’t mix ‘AND’ with ‘OR’ in a meta_query.

    You may need to first find all the posts using the meta_query you have, then loop over the results and remove (unset) the ones which don’t have the correct ‘status’ meta_value.

    Thanks
    E

  • Only on the front end.

    I’m using the gallery add-on which I purchased purely for the front-end ability to batch upload photos with the standard media upload UI. The gist of the rest of process (which is working):

    • ACF adds a select field to event post type that is populated with Gravity Forms for admin to select which registration form to use. That is displayed on upcoming events via template.
    • Create a CPT for galleries
    • ACF provides meta fields on gallery (eventID, photographer, email and multi-photo from add-on.

    The last piece is having the ACF form show up on event to allow batch upload of photos which is limited by the issue described above.

    I have a temporary workaround of putting a separate the photo submission form onto a separate page that populates the eventID via select field populated with past dated events. But requirement is that everything stays tied to the individual event along with comments, post-event feedback (GF) form.

  • Hi @Exelmans Graphics

    Thanks for the feature request, however a link can not be placed within a select field. Furthermore, this would not be possible to position the edit button above the select field due to the multi-select fields scroll ability.

    This feature will not be able to make it into the current version, but I will consider adding it in the future if new technology is available.

    Thanks
    E

  • Hi @vaggogol

    A Multi-select field requires you to hold shift, or cmd to select multiple items, much like using finder to select multiple files.

    Thanks
    E

  • Hi @navitronic

    Thanks for the info. The issue here is that upon clicking a taxonomy term, ACF fires an AJAX request to find field groups based on the current post.

    For some reason, it seems that the data being posted is not correct and causing the wrong field groups to be returned. This is causing the field group to hide.

    Can you provide a login account for me to test?

    Thanks
    E

  • could you post your query?

    also, the result which is indicate by your search being termed broken will help; for instance, do you receive any on screen errors?

    is this a development environment or a live environment, do you have wp_debug turned on?

  • Hi @nickfmc

    Just wanted to let you know I have pushed an update to github containing a filter for the user field $args.

    You can hook in and modify them like so:

    
    <?php 
    
    function my_acf_user_query( $args, $field, $post_id ) {
    	
    	// http://codex.wordpress.org/Function_Reference/get_users
    	$args['orderby'] = 'nicename';
    	
    	return $args;
    }
    
    add_filter('acf/fields/user/query/name=CUSTOM_FIELD_NAME', 'my_acf_user_query', 10, 3 );
    
    ?>
    

    You can also remove the /name=CUSTOM_FIELD_NAME for this to run on all user fields.

    Thanks
    E

  • Hi @EugeneNyawara

    This is a great question, and one which can be achieved by reading about querying posts via a sub field value here:
    http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/#example-5

    I have done some copy / paste and put together a template for you. Just replace {$repeater_field_name} with your repeater field name, and {$sub_field_name} with your sub field name, and it should work! Fingers crossed:

    
    <?php 
     
    // custom filter to replace '=' with 'LIKE'
    function my_posts_where( $where )
    {
    	$where = str_replace("meta_key = '{$repeater_field_name}_%_{$sub_field_name}'", "meta_key LIKE '{$repeater_field_name}_%_{$sub_field_name}'", $where);
     
    	return $where;
    }
     
    add_filter('posts_where', 'my_posts_where');
     
    // args
    $args = array(
    	'post_type'	=> 'whose-posts-we-want-to-display',
    	'meta_query' => array(
    		array(
    			'key' => '{$repeater_field_name}_%_{$sub_field_name}',
    			'value' => '"' . get_the_ID() . '"',
    			'compare' => 'LIKE'
    		)
    	)
    );
     
    // get results
    $the_query = new WP_Query( $args );
     
    // The Loop
    ?>
    <?php if( $the_query->have_posts() ): ?>
    	<ul>
    	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<li>
    			<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    		</li>
    	<?php endwhile; ?>
    	</ul>
    <?php endif; ?>
     
    <?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>
    

    Thanks
    E

  • Thanks for your quick suggestion, however I tried for quite a while now but can’t seem to find where to add that rule.

    I’m using your code from the documentation:

    <script type="text/javascript">
    (function($) {
     
    /*
    *  render_map
    *
    *  This function will render a Google Map onto the selected jQuery element
    *
    *  @type	function
    *  @date	8/11/2013
    *  @since	4.3.0
    *
    *  @param	$el (jQuery element)
    *  @return	n/a
    */
     
    function render_map( $el ) {
     
    	// var
    	var $markers = $el.find('.marker');
     
    	// vars
    	var args = {
    		zoom		: 16,
    		center		: new google.maps.LatLng(0, 0),
    		mapTypeId	: google.maps.MapTypeId.ROADMAP
    	};
     
    	// create map	        	
    	var map = new google.maps.Map( $el[0], args);
     
    	// add a markers reference
    	map.markers = [];
     
    	// add markers
    	$markers.each(function(){
     
        	add_marker( $(this), map );
     
    	});
     
    	// center map
    	center_map( map );
     
    }
     
    /*
    *  add_marker
    *
    *  This function will add a marker to the selected Google Map
    *
    *  @type	function
    *  @date	8/11/2013
    *  @since	4.3.0
    *
    *  @param	$marker (jQuery element)
    *  @param	map (Google Map object)
    *  @return	n/a
    */
     
    function add_marker( $marker, map ) {
     
    	// var
    	var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
     
    	// create marker
    	var marker = new google.maps.Marker({
    		position	: latlng,
    		map			: map
    	});
     
    	// add to array
    	map.markers.push( marker );
     
    	// if marker contains HTML, add it to an infoWindow
    	if( $marker.html() )
    	{
    		// create info window
    		var infowindow = new google.maps.InfoWindow({
    			content		: $marker.html()
    		});
     
    		// show info window when marker is clicked
    		google.maps.event.addListener(marker, 'click', function() {
     
    			infowindow.open( map, marker );
     
    		});
    	}
     
    }
     
    /*
    *  center_map
    *
    *  This function will center the map, showing all markers attached to this map
    *
    *  @type	function
    *  @date	8/11/2013
    *  @since	4.3.0
    *
    *  @param	map (Google Map object)
    *  @return	n/a
    */
     
    function center_map( map ) {
     
    	// vars
    	var bounds = new google.maps.LatLngBounds();
     
    	// loop through all markers and create bounds
    	$.each( map.markers, function( i, marker ){
     
    		var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
     
    		bounds.extend( latlng );
     
    	});
     
    	// only 1 marker?
    	if( map.markers.length == 1 )
    	{
    		// set center of map
    	    map.setCenter( bounds.getCenter() );
    	    map.setZoom( 14 );
    	}
    	else
    	{
    		// fit to bounds
    		map.fitBounds( bounds );
    	}
     
    }
     
    /*
    *  document ready
    *
    *  This function will render each map when the document is ready (page has loaded)
    *
    *  @type	function
    *  @date	8/11/2013
    *  @since	5.0.0
    *
    *  @param	n/a
    *  @return	n/a
    */
     
    $(document).ready(function(){
     
    	$('.acf-map').each(function(){
     
    		render_map( $(this) );
     
    	});
     
    });
     
    })(jQuery);
    </script>
  • Thanks guys. I’ve conjured up this, which in my mind should work:

    function same_youtube_options_controls_acf($content) {
      $content = get_sub_field('iframe_url'); 
        return str_replace("rel=0&", "rel0&&autohide=1&showinfo=0&controls=1&", $content);
    
    }
    
    add_filter('acf/load_field/name=iframe_url', 'same_youtube_options_controls_acf');

    However, the iframe_url just disappears.

    Sorry to be a pain.

  • Hi Elliot,

    Thank you for your reply. Your solution worked, thanks!

    But I really need the extra ‘status’ parameter. It’s an another custom field where I can mark the item as sold/reserved/for sale.
    How can I combine this with the meta_query?

    Thanks,
    Edwin

  • Hello,

    The generated html is as follows:

    <!-- Start Flexslider -->
    <div class="flexslider">
        <ul class="slides">
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_172_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_172_orig_copy.jpg" alt="" />
                </li>
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_CLS_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_CLS_orig_copy.jpg" alt="" />
                </li>
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_170_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_170_orig_copy.jpg" alt="" />
                </li>
            	<li data-thumb="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_30_orig_copy-150x150.jpg">
                    <img src="http://localhost:8888/wp-testing/wp-content/uploads/2014/02/128387_30_orig_copy.jpg" alt="" />
                </li>
         </ul>
    </div>
    <!-- End Flexslider -->

    Which is odd because it looks as if the images and thumbs should match up.

    I was using a Flexslider example and creating the thumbs in this line (from previous posted code)

    <li data-thumb="<?php echo $image['sizes']['thumbnail']; ?>">

    The Flexslider suggested code is as follows:
    JS

    // Can also be used with $(document).ready()
    $(window).load(function() {
      $('.flexslider').flexslider({
        animation: "slide",
        controlNav: "thumbnails"
      });
    });

    HTML

    <!-- Place somewhere in the <body> of your page -->
    <div class="flexslider">
      <ul class="slides">
        <li data-thumb="slide1-thumb.jpg">
          <img src="slide1.jpg" />
        </li>
        <li data-thumb="slide2-thumb.jpg">
          <img src="slide2.jpg" />
        </li>
        <li data-thumb="slide3-thumb.jpg">
          <img src="slide3.jpg" />
        </li>
        <li data-thumb="slide4-thumb.jpg">
          <img src="slide4.jpg" />
        </li>
      </ul>
    </div>

    I’ve kinda mashed these together after watching your vimeo video example.

    When I change the order of the thumbnails via the Gallery Field in the WP Post screen, should it (in theory) update the order of the thumbnails and full size images? (I understand it’s mostly likely me, so when I say ‘in theory’ I mean no offence!)

  • my last post got me wondering why there wasn’t an auto_incrementing field. that seemed highly unusual; in fact, according to this…wp_postmeta should not have any 0’s in the meta_id field since it is supposed to be an auto-incrementing field. i lost my indexes somewhere.

    https://codex.wordpress.org/Database_Description#Table:_wp_postmeta

    and, adding the indexes back fixes it! here are the queries i used if it helps anyone that somehow lost their indexes as well.

    alter table wp_postmeta change column meta_id id integer unsigned, add column meta_id integer unsigned primary key auto_increment first;
    update wp_postmeta set meta_id = meta_id + 9000; -- more than the number of rows in the table
    update wp_postmeta set meta_id = id where id <> 0;
    alter table wp_postmeta drop column id;
    alter table wp_postmeta add index (meta_key), add index (post_id);
  • This reply has been marked as private.
  • in narrowing it down, i can recreate using just this as my acf.php:

    <?php
    
    if(function_exists("register_field_group"))
    {
            register_field_group(array (
                    'id' => 'acf_experience-post-fields',
                    'title' => 'Experience Post Fields',
                    'fields' => array (
                            array (
                                    'key' => 'field_52bc856a5d6b9',
                                    'label' => 'Is Auction',
                                    'name' => 'is_auction',
                                    'type' => 'true_false',
                                    'instructions' => '',
                                    'message' => '',
                                    'default_value' => 0,
                            )),
                    'location' => array (
                            array (
                                    array (
                                            'param' => 'post_type',
                                            'operator' => '==',
                                            'value' => 'experience',
                                            'order_no' => 0,
                                            'group_no' => 0,
                                    ),
                            ),
                    ),
                    'options' => array (
                            'position' => 'normal',
                            'layout' => 'no_box',
                            'hide_on_screen' => array (
                            ),
                    ),
                    'menu_order' => 0,
            ));
    }
  • Hi @advancedcustomfields@swell.nl

    The relation should be OR to allow for any of the meta_query’s to match. I can’t explain why ALL the art appears.

    Firstly, can you change:
    $arrays[$i] = array(

    to:
    $arrays[] = array(

    I’m not sure if that is an important change, but I don’t think specific indexes are needed here.

    The main issue I can see is that your WP_Query has:

    'meta_key' => 'status',
    	'meta_value' => 'te koop',

    This will override the 'meta_query' => $arrays

    Please only use the 'meta_query' => $arrays

    Thanks
    E

  • I think you need to use get_field_object but don’t quote me – I’m learning as well. 🙂

    $choices = get_field_object('yourFieldKey');

    http://www.advancedcustomfields.com/resources/functions/get_field_object/

  • BAZINGA!!! I did the php.ini trick as described here

    and that seemed to do the work. Fanbloomintastic. Peace out ACF

  • Thanks for your respons.

    I figured it out, I made another if statement within like this:

    <?php
    if( get_field('te_koop') )
    {
    	if( qtrans_getLanguage() == 'en' ){
    		echo '<span class="sale">For sale</span>';
    	}
    	else 
    	{
    		echo '<span class="sale">Te koop</span>';
    	}
    }
    else
    {
    	echo '';
    }
    
    ?>
  • I’m not quite sure what you want to achieve.

    What i can say is, that your if statement needs an expression of the type boolean, which your field probably isn’t. (read this)

  • This is the code I use to display ALL of the releases. It works great.

    I need to somehow adapt this query to show only the Releases of a specific artist on their Artist page. Thought it might help…

    <?php
         $args=array(
         'post_type' => 'book',
         'post_status' => 'publish',
         'posts_per_page' => 12,
         'caller_get_posts'=> 1,
         'orderby'=> 'date',
         'order' => 'DESC'
         );
         $my_query = null;
         $my_query = new WP_Query($args);
         if( $my_query->have_posts() ) {
         echo '';
         $i = 0;
         while ($my_query->have_posts()) : $my_query->the_post();
         if($i % 6 == 0) { ?>
    <div class="row">    
    <?php
    }
    ?>
    
    <img src="<?php the_field('cover_image'); ?>" /><br />
    <?php the_field('author_name'); ?><br />
    <?php the_title(); ?><br />
    
    </div>
    
    <?php    
    if($i % 6 == 0) { ?> 
    
    <?php
    }
    
    $i++;
    endwhile;
     } 
    wp_reset_query();
    ?>
  • Elliot,
    Thanks for the quick response. I’m still not clear on how the Relationship Field could be used with Attachments (images) with the ability to see a thumbnail of the image you are selecting. If there is a way, I’d be interested in knowing.

    The good news is that I somehow missed the Repeater Field Add-On with the Image Sub Field, and that does look like it would work well for my needs.

    I was going to mark this as solved, but just curious about the first part of it if possible. It that part isn’t doable, just LMK and I can call it solved.

    Thanks!
    -Thomas

  • Hi Flowbob,

    Did you try using something like this in your custom theme page, I used fancybox:

    <a class="fancybox" rel="group" href="<?php the_field('name_custom_field'); ?>"><img src="<?php the_field('name_custom_field'); ?>" alt="<?php the_title(); ?>"/></a>

  • Is $field the search term entered into the relationship search box I tried

    function acf_relationship_content_search( $args, $field, $post ) {
        $args['s'] = $field;
        return $args;
    }
    add_filter('acf/fields/relationship/query', 'acf_relationship_content_search', 10, 3);

    to include the field in the wider search for post_content but no dice.

    Any help anyone can give me would be greatly appreciated.

    Thanks,

  • Hi guys,

    Thanks for your help firstly! I’m really impressed with the quality of this plugin, I know I’m trying to do something tricky here with only a working knowledge of PHP. Everything else I’ve used ACF for (lots of applications!) works like a charm straight out of the box.

    Now.

    I tried removing the postdata functions, but that doesn’t seem to have changed anything.

    Taking the $idlist declaration out of the loop does seem to have helped- I set up two test repeater rows and posts chosen in both are being affected.

    However – only the values from the last repeater row are being applied. I.e. I have two sales, one takes $50 off a group of posts, the second takes $150. Now all the posts selected are showing $150 reduction.

    This is the current code I’ve put in a test page template to get the print:

    if(get_field('sales', 'option')):
     
    	while(has_sub_field('sales', 'option')):
     
    		$saletype = get_sub_field('sale_type');
    		$discount = get_sub_field('discount_amount');
    		$saleitems = get_sub_field('devices_on_sale');
    
    		if( $saleitems ):
    		    foreach( $saleitems as $post):
    				$thisid = $post->ID;
    				$idlist[] = $thisid;
    		    endforeach;
    		endif;
    		
    		echo($discount);
    		print_r($idlist);
     
    	endwhile;
     
    endif;

    Which yields:
    100Array ( [0] => 3391 [1] => 3410 [2] => 3412 ) 150Array ( [0] => 3391 [1] => 3410 [2] => 3412 [3] => 1292 [4] => 751 )

    So by my understanding, this is adding both groups of selected posts to the same array.

    Perhaps during the foreach loop, the $post->$ID can be stored differently… I have a vague idea – what I need is not a single named array, but some kind of anonymous array that can be referenced differently somehow, when I need it?

    Alternatively, could I create a “name” text subfield for each repeater row to provide each row with a unique identifier, then reference the related array from that somehow?

    Argh! Any further help much, much appreciated! Cheers for having such great support!

Viewing 25 results - 18,826 through 18,850 (of 21,345 total)