Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Hi @fernandoalfaweb

    Sorry, but this question is a bit out of scope for the ACF support forum.

    Are you having any specific ACF issues regarding a bug or function problem?
    Or is this a general ‘how to’ question regarding WP AJAX?

    Thanks
    E

  • Hi @silverdarling

    Sorry mate, this doesn’t sound like a bug or issue with ACF, but a general ‘how to’ question regarding WP Dev.

    Unfortunately, this forum is only available for bugs / issues / simple questions. The above question will take quite a while for me to understand and then solve for you which I don’t have the time at the moment.

    If you have any issues regarding functions, please do ask away, but I can’t be of much help in this situation.

    Thanks for understanding

    Cheers
    E

  • Hi @cuberis

    Are you able to test in firefox OSX? Also, are you able to update ACF to the latest?

    Thanks
    E

  • Hi @MatsKruger

    Sorry, I can’t understand your question.
    It is very confusing. Can you re-write it being very clear about your issue?

    Thanks
    E

  • Hi @elliot,

    Okay, thanks for the clarification. I figured something wasn’t filtering in. That’s great news on making more options for ACF front end. For now, I am making some cool adjustments via the message field and simply adding wrapping divs for some neat combining with Bootstrap.

    Anyhow, RE the validation.. Yes, ACF is validating correctly, I think I phrased this question incorrectly. I would like to change the text for the validation error so its a little more user friendly… So something like “Opps, looks like something is missing” as opposed to the word “invalid.”

    Along those lines also, is there a way to place the validation error message next to the submit button? This again is regarding the front end submission.

    A couple suggestions that would be awesome regarding validation are:

    – the above if not currently possible
    – With the “Tabs” auto grouping, that the tab gets a class “acf-group-contains-error” or something if a field within the tab group has a validation error. This would allow styling of that tab to make it more obvious to the user.
    – Individual validation messages per field. So if I have a phone number field, i could customize the message for that specfic field to be “Please provide your phone number.” as opposed to a generic “field is required.”

    I tried messing around with some jQ to get the above working but was unsuccessful. I am definitely not the type to request something without first trying at least.

    Made the simple changes of .live to .on in all the addons, so I’m not worried.

    Thanks Elliot.

  • Hi Elliot

    Thanks for the quick reply……I’ve checked all the plugins carefully, and the only other one that does anything with post metadata is the All-in-One SEO pack, which we can’t get rid of.

    ACF does post the data just fine when it’s initially entered, it just doesn’t seem to update it if someone edits an existing Post and changes some of what was originally entered. I was testing on a Post where I ‘unhid’ the normal (WP) Custom Fields metabox, which shows the same key>value pairs as was entered using the ACF custom fields, but they don’t update if we change the data in the ACF fields, only if we change it in the (WP) Custom Fields…since we don’t give our users access to the WP Custom Fields, it seems like we can’t modify metadata…..

    Any other thoughts or suggestions?

  • Hi Elliot,

    It was a rather lengthy and involved process to clone out the site and run the tests as you requested — which is why it’s taken me 3 weeks to respond.

    After the clone I went through and disabled plugins one at a time to see if I could get the fields to show. No dice. It appears that the issue is between ACF and Advanced Access Manager as expected.

    Any thoughts? Should I just look for a different role management plugin?

    Thanks,
    Jake

  • Hi Elliot,
    I’m trying to do something similar. I tried the code above and it didn’t work for me.
    I’m trying to create a page with Events Listings. But I’d just like to use one repeater field that has about 6 sub-fields. One of those sub-fields is a selection field called “date_category” with a selection of Current Event and nothing else. So the user would then select if the event is current or if they select nothing, it will go into the archived section of the page. In my template, I’ve duplicated the repeater fields in both selections… see my code…I would actually like to place all the Archived Listings inside a Jquery accordion, so that all the archives would be hidden until the user expands them, but the current events would be listed one after the other, as normal. The problem is that my code creates an accordion for each listing, instead of grouping them all together under one accordion. See my code below. Is there a way to group them?

    Thanks for your help.

    <div class="events">
    <?php if(get_field('event_listings')): ?> 
    <?php while(has_sub_field('event_listings')): ?>
    						
    <?php  if(get_sub_field('date_category') == "Current Event") { ?>
    											    	
    <div class="event_listings">
    <div class="date"><strong>Event Date:</strong> <?php the_sub_field('date'); ?></div>	
    <div class="title"><?php the_sub_field('title'); ?></div>
    
    <p><?php the_sub_field('description'); ?></p>
    															
    <div class="meta"><strong>Time:</strong> <?php the_sub_field('time'); ?></div>
    <div class="meta"><strong>Location:</strong> <?php the_sub_field('location'); ?></div>
    <div class="meta"><strong>Attendance:</strong> <?php the_sub_field('attendance'); ?></div>
    <div class="meta"><strong>Type:</strong> <?php the_sub_field('type'); ?></div>
    </div><!--End Event Listings-->
    							
    
    <?php  } else { ?>
    							
    <div class="expand">Archived Listings</div>
    							
    <div class="event_listings collapse">
    <div class="date"><strong>Event Date:</strong> <?php the_sub_field('date'); ?></div>	
    <div class="title"><?php the_sub_field('title'); ?></div>
    																		
    <p><?php the_sub_field('description'); ?></p>
    															
    <div class="meta"><strong>Time:</strong> <?php the_sub_field('time'); ?></div>
    <div class="meta"><strong>Location:</strong> <?php the_sub_field('location'); ?></div>
    <div class="meta"><strong>Attendance:</strong> <?php the_sub_field('attendance'); ?></div>
    <div class="meta"><strong>Type:</strong> <?php the_sub_field('type'); ?></div>
    </div><!--End Event Listings-->
    							
    <?php } ?>
    						
    							
    <div style="margin-bottom:20px;"></div>
    <?php endwhile; ?> 
    <?php else : ?>
    <p>There are no event listings at this time.</p>
    <?php endif; ?>					
    </div>	
  • seems i have to do this using $wpdb …

    //average for all of post_type by assessor
    
    function q_average_assessor( $fieldname, $posttype, $assessor) {
    
    global $wpdb;
    $repeaterfieldname = 'values_and_outcomes_%_' . $fieldname;
    
     
    	// get all rows from the postmeta table where post_type = $postype AND has a repeater subfield of $fieldname
    	// - http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results
            $rows = $wpdb->get_results($wpdb->prepare( 
                "
                SELECT * 
                FROM wp_postmeta
                INNER JOIN wp_posts ON ( wp_posts.ID = wp_postmeta.post_id ) 
                WHERE wp_posts.post_type=%s
                AND wp_postmeta.meta_key LIKE %s
    
                
                ",
                $posttype,
                $repeaterfieldname
            ));
        
         $coreval = 0;
         $counter = 0;
    	// loop through the results
    	if( $rows )
    	{
    		foreach( $rows as $row )
    		{
    			// for each result, find the 'repeater row number' and use it to load the image sub field!
                preg_match('_([0-9]+)_', $row->meta_key, $matches);
    			$meta_key = 'values_and_outcomes_' . $matches[0] . '_' . $fieldname; // $matches[0] contains the row number!
     
    			//  use get_post_meta 
    			$thisassessor = get_post_meta( $row->post_id, 'assessor', true );
    			if($thisassessor == $assessor) {
    	         $counter++;
    	         $coreval = $coreval + get_post_meta( $row->post_id, $meta_key, true );
                }
    
     
    		}
    	}
    $paverage = $coreval / $counter;
    $average = round($paverage, 1);
    return $average;
    }

    but means a lot of my previous code is wrong. assumption is that for a query on an archive page (ie involving more than one post and repeater fields) get_posts() doesn’t work but $wpdb does?

  • Ok I think I figured out a solution for you to test. First we need to loop through the while( has_sub_field( 'schede_prodotti' ) ) and prepare the data for furhter use in $ids and $files. Next we use these arrays containing the $post->IDs from the relationship field and the $files from the other fields in the repeater and prepare our data to get out.

    Here is the code:

    <?php if ( get_field( 'schede_prodotti' ) ): ?>
    <table class="product-list simple-list">
        <?php
    
            $ids   = array(); // Empty array for the $post->IDs from the relationship fields
            $files = array(); // Empty array for the files from the repeater fields
    
            while( has_sub_field( 'schede_prodotti' ) ):
    
                /**
                 * Get the IDs
                 *
                 * Returns an array of the IDs of the posts
                 * selected using the Relationship field.
                 *
                 * @var array
                 */
                $id    = get_sub_field( 'relazione_prodotti' );
                $ids[] = $id[0]; // We need the first array of the return value of the relationship field
    
                /**
                 * Get the files
                 *
                 * Store the files under the $post->ID from the relationship field
                 * and use the field name for reference.
                 *
                 * @var $array
                 */
                $files[$id[0]]['scheda_tecnica'] = get_sub_field('scheda_tecnica');
                $files[$id[0]]['scheda_di_sicurezza'] = get_sub_field('scheda_di_sicurezza');
    
            endwhile; // has_sub_field( 'schede_prodotti' )
    
            if ( $ids ) : // Check if we have $ids from the posts.
    
                /**
                 * Prepare the get_posts arguments
                 *
                 * With the 'orderby' => 'ttile' we accomplish the goal of having the
                 * products ordered by name instead of drag and drop.
                 *
                 * @see http://codex.wordpress.org/Template_Tags/get_posts#Parameters
                 * @var array
                 */
                $args = array(
                    'post__in'  => $ids,        // Use the ids from above
                    'order'     => 'ASC',       // Order
                    'orderby'   => 'title',     // Field to order the posts by
                    'post_type' => 'prodotti'   // The custom post type you use
                );
    
                /**
                 * Query the Posts
                 *
                 * @var array
                 */
                $posts = get_posts( $args );
    
                if ( $posts ) : // Check if we have $posts
    
                    foreach ( $posts as $post ) : setup_postdata( $post ); ?>
                        <tr>
                            <td class="title">
                                <span><?php the_title(); ?></span>
                            </td>
                            <td>
                                <a href="<?php echo $files[$post->ID]['scheda_tecnica']; ?>" class="notifiche" data-tipo="Scheda Tecnica">Scarica la Scheda Tecnica</a>
                            </td>
                            <td>
                                <a href="<?php echo $files[$post->ID]['scheda_di_sicurezza']; ?>" class="notifiche" data-tipo="Scheda di Sicurezza">Scarica la Scheda di Sicurezza</a>
                            </td>
                        </tr><?php
    
                    endforeach; // ( $posts as $post )
                    wp_reset_postdata();
    
                endif; // ( $posts )
            endif; // ( $ids )
        ?>
    </table>
    <?php endif; // get_field( 'schede_prodotti' ) ?>

    And again I updated the Gist for better readability: https://gist.github.com/neverything/6573468

    Let me know if this works now with the sorting of the titles.

  • Hello Elliot

    Thx for the quick reply. This however didn’t fix the problem.

    If I take a look at the acf_form_wp_head function I see the following:

    function acf_form_wp_head()
    {
    	do_action('acf/input/admin_head');
    }

    So in fact I already did the do_action part, only from within a function (which I called in my custom code).

    I’ve tried some other placements for the do_action in my code but this didn’t work either. I’m not a frequent WordPress user so I’m not sure what to try next.

    This is the current situation:
    I’ve added a hook to a custom function:
    add_action('admin_head', 'cjobs_admin_head');

    In that function I’ve put the do_action:

    function cjobs_admin_head()
    {
    	do_action('acf/input/admin_head');
    }

    This is already something different than the code I used in version 3.x. In that version all I had to do was call the acf_form_wp_head function just before parsing the acf fields.

    This is the acf_form_wp_head function in version 3.x:

    function acf_form_wp_head()
    {
    	// global vars
    	global $post, $acf;
    
    	// Style
    	echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/global.css?ver=' . $acf->version . '" />';
    	echo '<link rel="stylesheet" type="text/css" href="'.$acf->dir.'/css/input.css?ver=' . $acf->version . '" />';
    
    	// Javascript
    	echo '<script type="text/javascript" src="'.$acf->dir.'/js/input-actions.js?ver=' . $acf->version . '" ></script>';
    
    	// add user js + css
    	do_action('acf_head-input');
    }
  • Hi Elliot, sorry for that – I’ll try

    Restart:
    I’m developing a theme.

    I have a custom post type – ‘trainings’

    I created a custom field group – ‘trainingcontent’ by using your plugin.
    within that group are 2 fields: a) description b) image

    Rule is set to display this custom field group, when Post Type is equal to trainings

    I have a couple of ‘trainingcontent’ to display on one page, what already works.

    But if I go to Admin dashboard –> ‘trainings’ –> ‘trainingcontent1’ (1st entry in the custom field group)
    there is a permalink shown in the post edit screen which looks like: http://www.mydomain.com/trainings/trainingcontent1

    by clicking this there is no page to display, I know it could be there if I put something in the single.php but I don’t want to display the single training content alone. It should only be displayed on the ‘trainings’ site together with other ‘trainingcontent’. Therefore I want to remove the permalink from each custom field group entry, like ‘trainingcontent1’, ‘trainingcontent2’ a.s.o.

    I want to have a permalink that looks this was:
    http://www.mydomain.com/trainings

    So far as I understand, each entry in the custom field group within that post, creates a new single-post and therefore wordpress creates a separate permalink.

    Maybe the repeater field could help me out, so that I could put this on a page instead of using a post?

    I hope this is less confusing to you.

    Regards, Guido

  • Yep I can use WP Image but that could work only for crop big images. My main problem is when someone upload an img smaller than my min required size.
    Anyway thanks for the answer. I’ll figured out a way to do this 😉

  • Hi @locomo

    Thanks for the question. You can use a JS filter to hook in and run validation on any field! This is not yet documented but does work.

    Use it like so:
    * Note, this is jQuery

    
    $(document).on('acf/validate_field', function( e, field ){
    	
    	// vars
    	$field = $(field);
    	
    	
    	// set validation to false on this field
    	if( $field.find('input').val() == 'test' )
    	{
    		$field.data('validation', false);
    	}
    		
    });
    
  • Hi guys.


    @Jonathan
    – nice code, but I think you need to reference global $post within the function like so:

    
    function example($field, $postID) {
    
         global $post;
    
         $post_object = get_field($field, $postID);
         
         if($post_object) {
              // get post data
    	  $post = $post_object;
        	  setup_postdata($post);
              ?>
                   <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
              <?php
              // reset postdata
    	  wp_reset_postdata();
         }
    }
    
    example(&#039;my_post_object&#039;, $post->ID); //in your template, assuming you do this inside the loop. If outside try replacing $post->ID with get_the_ID()
    ?>
    
  • Hi @[email protected]

    Sorry, I am completely baffled by your question. Can you please re-write it in a way that is clear, straightforward and non confusing.

    Thanks
    E

  • Hi @Nuro

    Sorry, I don’t understand the question.

    You are using a repeater field to store all the category data?

    I think you would be better off just using the get_terms function to loop through the terms and render the data you want.

    Perhaps you could explain the issue with a bit more clarity?

    Thanks
    E

  • Ok, just checked out the code on a demo site I created with your XML file. I’m not sure, but we might forgot to tell WordPress about your post_type => ‘prodotti’ in the query. Could you please check if the following code works for you?

    <?php if ( get_field( 'schede_prodotti' ) ): ?>
    <table class="product-list simple-list">
        <?php while( has_sub_field( 'schede_prodotti' ) ): ?>
        <tr>
            <td class="title">
            <?php
                /**
                 * Get the IDs
                 *
                 * Returns an array of the IDs of the posts
                 * selected using the Relationship field.
                 *
                 * @see Screenshot: Change return value from Post Objects to Post IDs
                 * @var array
                 */
                $ids = get_sub_field( 'relazione_prodotti' );
                // var_dump( $ids ); //uncomment this line to see the $ids getting loadded
    
                /**
                 * Prepare the get_posts arguments
                 *
                 * With the 'orderby' => 'ttile' we accomplish the goal of having the
                 * products ordered by name instead of drag and drop.
                 *
                 * @see http://codex.wordpress.org/Template_Tags/get_posts#Parameters
                 * @var array
                 */
                $args = array(
                    'post__in'  => $ids,    // Use the ids from above
                    'order'     => 'ASC',   // Order
                    'orderby'   => 'title',  // Field to order the posts by
                    'post_type' => 'prodotti' // We might forgot about your post type...
                );
    
                /**
                 * Query the Posts
                 *
                 * @var array
                 */
                $posts = get_posts( $args );
    
                if ( $posts ) :
    
                    foreach ( $posts as $post ) : setup_postdata( $post ); ?>
    
                        <span><?php the_title(); ?></span><?php
    
                    endforeach;
                    wp_reset_postdata();
    
                endif; // ( $posts )
            ?>
            </td>
            <td>
                <a href="<?php the_sub_field('scheda_tecnica')?>" class="notifiche" data-tipo="Scheda Tecnica">Scarica la Scheda Tecnica</a>
            </td>
            <td>
                <a href="<?php the_sub_field('scheda_di_sicurezza')?>" class="notifiche" data-tipo="Scheda di Sicurezza">Scarica la Scheda di Sicurezza</a>
            </td>
        </tr>
    
        <?php endwhile; // has_sub_field( 'schede_prodotti' ) ?>
    </table>
    <?php endif; // get_field( 'schede_prodotti' ) ?>

    You’ll find that I updated two lines:
    https://gist.github.com/neverything/6573468#file-acf-php-L17 and the more important one: https://gist.github.com/neverything/6573468#file-acf-php-L32

    Please let me know if this works for you and if not, please tell me so I’ll gladly have a look at your WordPress installation. Attached you find a screenshot of the working example table I rendered on my demo site.

  • Hey Jonathan –

    I gave that a shot but it isn’t working, and I think it’s because I am trying to access this data from within a foreach loop, like so:

    <div class="news-container">
    
    <?php $news = get_field('ssm_featured_content'); ?>
    
    <?php foreach ($news as $item) { ?>
    
    	<?php $postObject = get_sub_field('ssm_featured_page'); ?>
    	
    	<?php echo $postObject->$post_title; ?>
    	
    	
    <?php } ?>
    
    </div>
    <!-- end .news-container -->

    I tried to adjust as follows, but I am not sure how the code should look:

    <?php echo $item[$postObject->$post_title]; ?>

    but that didn’t seem to be correct either. I’m just not sure how to handle this.

    Rich

  • I think you’ll have to pass along the current posts id as well (or use global $post)..

    
    <?php
    function example($field, $postID) {
         $post_object = get_field($field, $postID);
         
         if($post_object) {
              # get post data
    	  $post = $post_object;
        	  setup_postdata($post);
              ?>
                   <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
              <?php
              # reset postdata
    	  wp_reset_postdata();
         }
    }
    
    example('my_post_object', $post->ID); //in your template, assuming you do this inside the loop. If outside try replacing $post->ID with get_the_ID()
    ?>
    
    
  • I’ve worked with ACF and WPML quite a bit myself and we’ve developed the habit that if you want to create a translation with the content copied you’d have to go into the post/page and then duplicate it, head over to the new post/page and hit the translate separately button.

    I’m not surprised why WPML blame ACF. Honestly my experience with their support is pretty lousy (and I’m not the average joe who run a hobby-site). I’m not saying the issue isn’t with ACF but to my knowledge ACF uses standard post_meta values which WPML should be able to copy when making a new translation.. I’ve made a copy-function of my own involving ACF meta fields without issues (not related to WPML) so…

  • Thanks for the quick response. This appears to be what I was looking for…turns out I forgot to use “sub” in get_sub_field, like an idiot

    Rich

  • Sorry Nuro, I have another question.

    I want to get all the values of the field ‘hair_color’.
    Is in a generic page to make a combobox to use it as a filter, so I need all the values. I don’t have the term-id value.

    Thanks in advance

  • same question asked in old forum: http://old.support.advancedcustomfields.com/discussion/6151/feature-request-direct-drag039n039drop

    and now its time to ask again :D. are there any news about that? also would love to see a way to write title and alt text direct in list view instead of opening each image.
    thanks!

  • Hi @jmeiii

    Here is a snippet of code for you to use.

    It will load the repeater field, then shuffle the rows and then loop through the rows and render the HTML.

    Please note you can’t use any of the sub field functions with this code:

    
    <?php 
    
    $rows = get_field('career_grid');
    if($rows)
    {
    	shuffle( $rows )
     
    	foreach($rows as $row)
    	{
    		$image = wp_get_attachment_image_src( $row['image'], 'full' );
    		
    		?>
    		<a href="<?php echo $row['link']; ?>">
    			<img src="<?php echo $image[0]; ?>" alt="<?php echo $image['alt']; ?>" />
    		</a>
    		<?php
    	}
     
    	
    }
    
    ?>
    
Viewing 25 results - 20,426 through 20,450 (of 21,337 total)