Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • You were actually wonderfully helpful. You helped me realize that I needed to just add another meta query field for the different series’. Now I’ve got it working perfectly! Thank you!

  • Since you are using the layout custom field, you should probably also take a look at this post…

    php-input-variables-exceeded-1000

    On complex field groups it is possible for the number of form variables submitted to exceed your web server’s maximum number of allowed variables per post. This happened to me on what seemed like a field group that wasn’t all that big. But once you start repeating layouts, the number of inputs can become quite large.

    Until the developers start using a different method of saving data (like I suggested in my post) you will either have to change the configuration of your web server (not always possible on shared web hosting) or figure out a different way to do it.

  • Sorry I just realized I should have added it as a code

    add_action('woocommerce_single_product_summary',"finish_image",22);
    
    function finish_image() {
    
    $terms = get_the_terms( $post->ID , 'pa_metal-finish' );
    if($terms) {
       foreach( $terms as $term ) {
    
      echo '<b>Finish:</b>'. '<img src= '<?php get_field('finish_img', 'pa_metal-finish'. '_' .$term->term_id);' ?>' />'
    }
    }
    }
    	
    	
  • I am so close, keep coming up with a parce error. What am I doing wrong here? I know it has something to do with the IMG SRC and quotes

    add_action(‘woocommerce_single_product_summary’,”finish_image”,22);

    function finish_image() {

    $terms = get_the_terms( $post->ID , ‘pa_metal-finish’ );
    if($terms) {
    foreach( $terms as $term ) {

    echo ‘<b>Finish:</b>’. ‘term_id);’ ?>’ />’
    }
    }
    }

  • I have gotten the image url to show back up if I give the full path to a single Attribute.

    add_action(‘woocommerce_single_product_summary’,”finish_image”,22);

    function finish_image() {
    echo ‘<b>Finish:</b>’. get_field(‘finish_img’, ‘pa_metal-finish_79’);
    }

    But I need the code to search though the metal finish attributes to find the one that applies to that Item.

    I know its something like the post found here.

    https://support.advancedcustomfields.com/forums/topic/get-field-from-woocommerce-attribute-taxonomy/

    but I cant seem to quite figure it out, do you have any insite?

  • It too confused me at first since the filter kind of sounds like it’s editing the active toolbar but in the documentation of the hook it says:

    Once a new toolbar is added to the list, it will then appear in the WYSIWYG field’s options when editing the field group.

    So I added the code in your question and sure enough if I go back to edit the Field Group in Custom Fields there’s a new radio button on the WYSIWYG Field labeled ‘Very Simple’ and when selected will only display a toolbar with bold, italic, and underline buttons on it.

  • A couple questions:

    1) Do you mean on the front-end, you’re unsure how to check against the selected radio button?

    IF you’re asking questions about the Admin Panel…

    2) Are these things ( radio buttons, images ) all part of the same Field Group?

  • I get what you’re trying to do, and I’ll post the code below with how to do it using a flat array but it’s unclear what the_query is or how it relates to Advanced Custom Fields. Until the actual code you’re using is posted the below may be a good starting point for you:

    <?php
    $image_array = query(); // Whatever you're using to query the images
    
    // Ensure have an image array to work with
    if( ! empty( $image_array ) ) { 
    	
    	$per_block   = 4;
    	$total_items = count( $image_array );
    	
    	foreach( $image_array as $index => $image_id ) {
    		
    		$nice_index = $index + 1;		// Arrays start at 0 but count and per block start at 1. Calculate once.
    		$start = ( 0 == $index % 4 );	// Calculate if we're at the start
    		$end   = ( $nice_index == $per_block || $nice_index == $total_items );	// Check if we've hit the end
    		
    		// Display Opening Tag
    		if( $start ) {
    			print( '<div class="col-md-3">' );	
    		}
    
    			// Display image by ID
    			wp_get_attachment_image( $image_id, 'full' );
    		
    		// Display Closing Tag
    		if( $end ) {
    			print( '</div>' );
    		}
    		
    	} // END Foreach
    	
    } // END Conditional
  • You should be able to hook into the admin footer and add in any kind of datepicker option as you need by field ID:

    /**
     * Modify ACF Datepicker Formatted Field
     *
     * @return void
     */
    function theme_prefix_admin_footer() {
    
    	?>
    
    		<script>
    
    			jQuery( document ).ready( function( $ ) {
    		
    				let $datepicker = $( '#acf-field_5b16a9d5df47c + .hasDatepicker' );
    				
    				$datepicker.datepicker( 'option', {
    					altFormat: 'dd. M yy'
    				} );
    				
    			} );
    
    		</script>
    
    	<?php
    
    }
    add_action( 'admin_footer', 'theme_prefix_admin_footer' );
  • I’m not sure if ACF has a field like this ( not that I could see in the basic version anyway ) but this type of thing would work best as a Non Hierarchical Taxonomy with a Select2 type field. Think post tags: it’s searchable, you can assign multiple, and it’s listed out in a formatted easily manageable input for the user to digest. You can control whether the user will be able to create new terms or only select from existing terms. You can populate with AJAX and give them a populated list of options. It seems to make sense for the usecase described.

    Terms is pretty efficient when querying because of the relational tables already setup. A custom table and query may be more efficient but would also be more work to setup.

  • Thanks John.

    I ended up using https://github.com/birgire/wp-combine-queries to blend a mostly-normal author posts query with one showing posts where the user is a participant:

    
    function author_include_when_contributor( $query ) {
        if ( !is_admin() && $query->is_main_query() && is_author() ) {
            $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
            $authorArgs = array(
                'post_type'     =>  array('post', 'podcast', 'resources', 'video'),
                'author'        =>  $curauth->ID,
                'orderby'       =>  'post_date',
                'order'         =>  'ASC',
            );
            $contributorArgs = array(
                'post_type' => array('post', 'podcast', 'resources', 'video'),
                'meta_query' => array(
                    array(
                        'key'     => 'participants',
                        'value'   => $curauth->ID,
                        'compare' => 'LIKE'
                    ),
                ),
                'orderby'       =>  'post_date',
                'order'         =>  'ASC',
            );
            $query->set( 'combined_query', [        
                'args'   => [ $authorArgs, $contributorArgs ],
                'union'  => 'UNION',
            ]);
        }
        return $query;
    }
    add_action( 'pre_get_posts', 'author_include_when_contributor' );
    

    I also presented the participants using this on the post:

    
    <?php
    $contributors = get_field('participants'); // array of arrays of user info
    if (!empty($contributors)) {
    	foreach ($contributors as $contributor)
    	{ ?>
    		<div class="col-md-3 col-sm-4 col-xs-2 tac contributor-badge">
    			<a href="<?php echo get_author_posts_url( $contributor ); ?>">
    				<div class="author-image-swap">
    					<?php if ( get_field('primary_picture', 'user_' . $contributor ) ) { ?>
    						<img data-object-fit src="<?php echo get_field('primary_picture', 'user_' . $contributor ); ?>" alt=""/>
    					<?php } elseif (get_the_author_meta('author_profile_picture', $contributor )) { ?>
    						<img data-object-fit src="<?php echo get_the_author_meta('author_profile_picture', $contributor ); ?>" alt="">
    					<?php } else { ?>
    						<img data-object-fit src="<?php echo get_avatar( $contributor, 512 ) ?>" alt=""/>
    					<?php } ?>
    					<?php if ( get_field('secondary_picture', 'user_' . $contributor ) ) { ?>
    						<img data-object-fit src="<?php echo get_field('secondary_picture', 'user_' . $contributor ); ?>" alt="">
    					<?php } ?>
    				</div>
    				<p class="large"><strong><?php echo get_the_author_meta('display_name', $contributor->ID); ?></strong></p>
    				<p><em><?php echo get_field('role', 'user_' . $contributor ); ?></em></p>
    			</a>
    		</div>
    	<?php }
    }
    ?>
    
  • When validating values you need to take the backslashes into account. No it is not happening only to you, but is the way that the values are passed. This can be caused by your php installation and the “Magic Quotes” setting.

  • Add the code to your choices

    
    facebook : <img src="https://image.flaticon.com/icons/png/128/69/69407.png" alt="https://image.flaticon.com/icons/png/128/69/69407.png" />
    twitter : image for twitter
    etc : etc
    
  • Querying by a repeater row is problematic. There are literally hundreds of topics on this forum on the subject. There is an example of how to do this on this page, but I don’t know if it still works https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    You should read my opinion on this and then decide how you want to go https://acfextras.com/dont-query-repeaters/

  • @marcusw I don’t see anything wrong with your query that should cause it to not function. The value of the field should have quotes around it, otherwise a value like this would also return posts

    
    a:3:{i:0;s:1:"5";i:1;s:1:"1";i:2;s:1:"3";}
    

    if the user id you are querying for is “2”, without the quotes the array index 2 would return this post.

    The only thing I can think of by looking at your query args is that either $post_type or $current_user_id is incorrect.

    Another cause of your issue would be if you originally saved values to the field when it was set to only allow a single user and then you changed the field to allow multiple users. In this case the field value will be holding an integer instead of an array.

    This change to the meta query might correct for that

    
    
    'meta_query'     => array(
      'relation' => 'OR',
      array(
        'key'     => 'shift_volunteers',
        'value'   => '"' . $current_user_id . '"',
        'compare' => 'LIKE'
      ),
      array(
        'key'     => 'shift_volunteers',
        'value'   => $current_user_id,
        'compare' => '='
      ),
    ),
    
  • For anyone too lazy to go look at the Codex, here it what I used:

    
    // example custom post type is "event"
    // example custom taxonomy is "events-category"
    
    function remove_default_event_category_metabox() {
    	remove_meta_box( 'tagsdiv-events-category', 'event', 'side' );
    }
    add_action( 'admin_menu' , 'remove_default_event_category_metabox' );
  • Thanks @magicstick

    I suspect my naming conventions are conflicting – should the variable be different for each subfield or does the subfield name itself need to be different.

    I think I’m dreading the answer…

    <?php
    
    if ( ! post_password_required() ) {
    		
    // check if the flexible content field has rows of data
    if( have_rows('page_content') ):
    
    	// loop through the rows of data
        while ( have_rows('page_content') ) : the_row();
        
        
      //100% row, no padding, for slider
    	if( get_row_layout() == 'fullwidth' ):
    
    		// check if the nested repeater field has rows of data
    		if( have_rows('fullwidth') ):
    
    			// loop through the rows of data
    		    while ( have_rows('fullwidth') ) : the_row();
    
    				$content = get_sub_field('content');
    				$colour = get_sub_field('background_colour'); ?>
    				
    				<div class="clearfix <?php echo $colour; ?>">
    
    					<?php echo $content; ?>
    
    				</div>
    				
    			<?php endwhile;
    
    		endif; 
    		
         endif; //END Single Row
    
    	 //Row with no padding
    		if( get_row_layout() == 'nopad' ):
    
    			// check if the nested repeater field has rows of data
    			if( have_rows('nopad') ):
    
    				// loop through the rows of data
    			    while ( have_rows('nopad') ) : the_row();
    
    					$content = get_sub_field('content');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container">
    
    							<div class="padme">
    								
    								<?php echo $content; ?>
    								
    							</div>
    
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END Single Row
    
    		//SINGLE ROW 
    		if( get_row_layout() == 'single_row' ):
    
    			// check if the nested repeater field has rows of data
    			if( have_rows('single_row') ):
    
    				// loop through the rows of data
    			    while ( have_rows('single_row') ) : the_row();
    
    					$content = get_sub_field('content');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container padout">
    
    							<div class="padme">
    								
    								<?php echo $content; ?>
    								
    							</div>
    
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END Single Row
    
    		  //SINGLE ROW contained
            if( get_row_layout() == 'single_row_small' ):
    
            // check if the nested repeater field has rows of data
            if( have_rows('single_row_small') ):
    
    				// loop through the rows of data
    			    while ( have_rows('single_row_small') ) : the_row();
    
    					$content = get_sub_field('content');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container-sm padout">
    
    							<div class="padme">
    								
    								<?php echo $content; ?>
    
    							</div>
    
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END Single Small
            
            
            
            
            
    
    		// check current row layout
    		if( get_row_layout() == '2_columns_5050' ):
    
    	      // check if the nested repeater field has rows of data
    			if( have_rows('2_columns_5050') ):
    
    				// loop through the rows of data
    			    while ( have_rows('2_columns_5050') ) : the_row();
    
    					$left = get_sub_field('column_left_50');
    					$right = get_sub_field('column_right_50'); 
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container padout">
    					
    							<div class="col-md-6 center-block padme">
    											
    								<?php echo $left; ?>
    			
    							</div>
    
    							<div class="col-md-6 center-block padme">
    
    									<?php echo $right; ?>
    									
    							</div>
    						
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END 2 columns 5050
            
    
    		// check current row layout
            if( get_row_layout() == '2_columns_7030' ):
    
            // check if the nested repeater field has rows of data
            if( have_rows('2_columns_7030') ):
    
    				// loop through the rows of data
    			    while ( have_rows('2_columns_7030') ) : the_row();
    
    					$title = get_sub_field('title');
    					$left = get_sub_field('column_left_70');
    					$right = get_sub_field('column_right_30');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container padout">
    							
    							<h2 class="text-center"><?php echo $title; ?></h2>
    																
    								<div class="col-md-9 padme">
    
    									<?php echo $left; ?>
    									
    								</div>
    
    								<div class="col-md-3 padme">
    									
    									<?php echo $right; ?>
    
    								</div>
    																	
    							</div>
    						
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END 2 columns 7030
            
            
            
    
    		// check current row layout
            if( get_row_layout() == '3_columns' ):
    
            // check if the nested repeater field has rows of data
            if( have_rows('3_columns') ):
    
    				// loop through the rows of data
    			    while ( have_rows('3_columns') ) : the_row();
    
    					$title = get_sub_field('title');
    					$left = get_sub_field('column_left');
    					$middle = get_sub_field('column_middle');
    					$right = get_sub_field('column_right');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container padout">
    							
    							<h2 class="text-center"><?php echo $title; ?></h2>
    
    								<div class="col-md-4 padme center-block">
    
    									<?php echo $left; ?>		
    									
    								</div>
    
    								<div class="col-md-4 padme center-block">
    
    									<?php echo $middle; ?>
    									
    								</div>
    										
    								<div class="col-md-4 padme center-block">
    									
    									<?php echo $right; ?>
    
    								</div>
    						
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END 3 columns
    
    		// check current row layout
            if( get_row_layout() == '4_columns' ):
    
            // check if the nested repeater field has rows of data
            if( have_rows('4_columns') ):
    
    				// loop through the rows of data
    			    while ( have_rows('4_columns') ) : the_row();
    
    					$title = get_sub_field('title');
    					$col1 = get_sub_field('column_1');
    					$col2 = get_sub_field('column_2');
    					$col3 = get_sub_field('column_3');
    					$col4 = get_sub_field('column_4');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    						
    						<div class="container padout">
    							
    								<h2 class="text-center"><?php echo $title; ?></h2>
    											
    								<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
    
    									<?php echo $col1; ?>
    									
    								</div>
    
    								<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
    
    									<?php echo $col2; ?>
    									
    								</div>
    										
    								<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
    									
    									<?php echo $col3; ?>
    
    								</div>
    								
    								<div class="col-lg-3 col-md-6 col-sm-12 padme center-block">
    									
    									<?php echo $col4; ?>
    
    								</div>
    								
    																	
    							</div>
    						
    						</div>
    						
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END 4 columns
    
    		// check current row layout
            if( get_row_layout() == 'background_image' ):
    
            // check if the nested repeater field has rows of data
            if( have_rows('background_image') ):
    
    				// loop through the rows of data
    			    while ( have_rows('background_image') ) : the_row();
    
    					$bgimage = get_sub_field('image');
    					$caption = get_sub_field('caption'); ?>
    					
    					<div class="clearfix">
    
    						<div class="parallax-sm" data-bs-parallax-bg="true" style="background-image:url(<?php echo($bgimage); ?>);">
    						
    							<h2 class="title text-center"><?php echo $caption; ?></h2>
    							
    						</div>
    					
    					</div>
    					
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END 2 columns 7030
    
    		// check current row layout
            if( get_row_layout() == 'youtube_video' ):
    
            // check if the nested repeater field has rows of data
            if( have_rows('youtube_video') ):
    
    				// loop through the rows of data
    			    while ( have_rows('youtube_video') ) : the_row();
    
    					$embedlink = get_sub_field('embed_link');
    					$info = get_sub_field('info');
    					$colour = get_sub_field('background_colour'); ?>
    					
    					<div class="clearfix <?php echo $colour; ?>">
    	
    						<div class="container">
    
    							<?php echo $info; ?>
    							
    							<div class='embed-container'>
    								
    								<iframe src='https://www.youtube.com/embed/<?php echo $embedlink; ?>' frameborder='0' allowfullscreen></iframe>
    								
    							</div>
    			
    						</div>
    					
    					</div>
    													
    				<?php endwhile;
    
    			endif; 
    			
            endif; //END YouTube
    
        endwhile;
    
    else :
    
        // no layouts found
    
    endif;
    
    }
    
    ?>
  • This is my final code so far ! And its working .. Thanks John

    <script>  
        <?php 
           $ea_args = array(
            'post_type'        => 'event-main',
            'posts_per_page'   => -1,
           
               );
            $ea_query = new WP_Query( $ea_args ); 
    	    
            if ( $ea_query->have_posts() ) {
    		$dates_enable = array();
    			
             while ( $ea_query->have_posts() ) {
              $ea_query->the_post(); 
                   $dates_enable[] = get_field('event_the_date');
               }
    		$dates_js_array = json_encode($dates_enable);
            } // end if
    wp_reset_query();
        ?>  
        var enableDays = <?php echo $dates_js_array; ?>;
        console.log(enableDays);
    </script>
  • For anyone who comes across this, the best solution that I found was this tool: https://github.com/mcguffin/acf-quick-edit-fields

    This saved me an hour or two of manually updating 181 posts. After installing that plugin, I edited the ACF field and checked off the option “Allow editing this field in Bulk edit mode” then I was able to bulk edit the posts and update the field.

  • @Jeff For some reason, the fields popped back up on their own and included all the original data stored for that page. I tried the method you proposed when the problem persisted, but it unfortunately did not fix the problem. It only created duplicate fields without the original data. As this is fixed – magically – I will mark your answer as having solved my question. Thanks for the response!

  • This reply has been marked as private.
  • I’ve been encountering this quite a bit the last couple of weeks as well.

    The latest site was running 5.7.3 and was showing “Automatic update is unavailable for this plugin” on the Plugins page. I went to Dashboard -> Updates and tried running the update there, which failed saying the package was not available. I refreshed the Updates page using the “Check Again” button, then went back to the main Plugins page and the notice was gone. I was able to successfully update at that point.

    Will have to give it a try on the various other sites I’m working on to see if that works consistently.

  • This $date_field_array = get_field('event_the_date'); only gets a single value from a single post.

    To get all values from all posts you first need to do a query to get all the posts, then you need to loop though all of those posts and get the field from each post.

    
    $args = array(/* your query args here */);
    $my_query = new WP_Query($args);
    if ($my_query->have_posts()) {
      $dates = array();
      while (($my_query->have_posts()) {
        $my_query->the_post();
        $dates[] = get_field('event_the_date');
      }
      // output dates to JS here
    }
    
  • Basically you need to look at this https://codex.wordpress.org/AJAX_in_Plugins

    When you enqueue the script you do it something like this, please note that this is only an example of the values that will be used. You should really look at the document and read about getting the admim ajax url and all of that

    
    wp_enqueue_style('your-handle', '/wp-admin/admin-ajax.php?action=my_custom_css_action');
    

    Then you create an action functin that outputs your dynamic php stylesheet.

  • You can’t enqueue a php file normally as a stylesheet and have it work.

    For example, this will not work

    
    wp_enqueue_style('your-handle', 'your-file.php');
    

    the reason for this is not that WP will not enqueue it or add it to your page. This issue is that no WP or plugin function will be available in this file.

    Your 2 choices are to put the custom styles inline in the header of your page or to enqueue the style script using admin-ajax.php

Viewing 25 results - 9,251 through 9,275 (of 21,340 total)