Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Thanks John, I replaced your response into the query but still not getting a URL (or anything returned) still – did I got the below right?

    <?php $image_file = get_sub_field( 'image_file' ); ?>
    <?php $image = wp_get_attachment_image_src( $image_file, $size );?>
    <?php $url = $image[0]; ?>
    <?php $size = 'overview'; ?>
    
    <?php if ( $image_file ) : ?>
    
    <?php wp_get_attachment_image_src( $image_file,  $size = 'overview',  $icon = false );?>
    
    <?php endif; ?>
  • This is a WP question and you’re more likely to get an answer from them. However, it seems that it’s not possible https://wordpress.org/support/topic/how-to-create-block-templates-for-specific-page-templates/

  • In order for fields to appear and for there to be a location the page must be either post type of a taxonomy. The URL indicates a custom admin page

    edit.php?post_type=course&page=sensei_grading&user=1&quiz_id=4332

    This cannot be used for an acf location rule because this page does not call any of the hooks used by ACF for adding custom fields.

    This type of page is similar to the page located at options-general.php. ACF cannot be used to add fields to these places.

    To do this would require altering the template or function that shows the form on the page and using acf_form() with the “form” argument set to false to insert the ACF form between the form tags of the other existing form. Depending on the plugin it might be possible that they provide some type of hook to do this but not in most cases. You need to contact the developer of the other plugin and find out if they provide any mechanism for modifying the form on that admin page.

  • You would need to do a WP query to get all the posts with that value, see this https://www.advancedcustomfields.com/resources/query-posts-custom-fields/

    loop over the posts and then use update_field() to update a value in another field of that post inside the loop.

  • I am using ACF(Free) plugin and I need help regarding the same. I created a checkbox field like the attached “Image 1”:
    Image 1

    I added the conditional logic but it is only showing one group fields, I need to populate multiple groups according to the selection in checkbox values. Is it possible using ACF?
    Image 2

    Thanks in advance

  • Any solution to this yet? I am on WordPress 5.9.1 (Multisite) with ACF Pro 5.12.2.

    I tried the code from https://support.advancedcustomfields.com/forums/topic/update-to-wp-5-9-1-breaks-media-selection/#post-152581 and it did not work.

    From what all I read thus far, it seems to the only solution is to role WordPress back to 5.9? Any quick help would be appreciated.

    My media selection modal appears.. however content area is blank in the “Upload files” and “Media Library” tabs.

  • Using a URL field.

    
    <a href="<?php the_field('url_field_name'); ?>" target="_blank">Visit the website</a>
    
  • Not sure why my original answer got marked as private but here’s what I originally provided as solution:

    <?php if( get_field('preco') && get_field('checked')): ?>
    <div class="container"> 
    	<div class="row">
    		<div class="col">
    			<?php if( get_field('preco') ): ?>
    			<p> <?php the_field('preco'); ?> </p>
    			<?php endif; ?>
    		</div>
    	
    		<div class="col">
    			<?php $ratingstar = get_field('checked'); ?>
    			<span class="fa fa-star <?php if ($ratingstar >= 1) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar >= 2) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar >= 3) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar >= 4) { echo 'checked';}?>"></span>
    			<span class="fa fa-star <?php if ($ratingstar == 5) { echo 'checked';}?>"></span>
    		</div>
    	</div>
    </div>
    <?php endif; ?>

    The “if” condition in the first line (together with “endif” in the last line) hide the content if there is no value.

  • I just found the correct answer
    <script type=”text/javascript”>
    (function($) {
    acf.add_filter(‘time_picker_args’, function( args, $field ){
    args.hourMin= 7;
    args.hourMax= 22;
    args.stepMinute = 15;
    args[‘showSecond’] = false;
    return args;
    });

    })(jQuery);

    </script>

    on this site all the args name for timepicker are listed
    https://trentrichardson.com/examples/timepicker/

  • What is the arg key for mintime and maxtime? Have you found the answer🤣, I notice you asked same question two years ago.

  • This is not an ACF question. You need to look at how to create this type of thing with HTML or whatever it is that you’d use. You’re not going to find someone here that can help you build an application like the image you’ve posted.

  • This cannot be done. In order to order by a field the values must all have the same meta key and this is not the case with repeater sub fields.

    See this

  • Where do we need to add required.php file?

  • There is no work-a-round. I was just doing some testing to see what happens and you just can’t order posts by a field that does not exist on every post.

    What you have to do is to create this field with a default value on every “product”

    
    add_filter('init', 'update_all_product_acf_field');
    // query to get all posts that are missing the meta value
    function update_all_product_acf_field() {
      $args =array(
        'post_type' => 'your-post_type', // change to correct post type
        'posts_per_page' => -1, // all mosts
        'meta_query' => array(
          array(
            // missing this field
            'key' => 'show_on_first_page',
            'compare' => 'NOT EXISTS',
          ),
        ),
        'fields' => 'ids' // all we need is the id
      );
      $query = new wp_query($args);
      if (!empty($query->posts)) {
        foreach ($query->posts as $post_id) {
          // use field key for your field
          // because it does not exist
          update_field('field_XXXXXXX', 0, $post_id);
        }
      }
    }
    

    More then likely the above will time out the loading of your site one or several times. When the site is able to load you can remove the init action because all the posts will be updated…. (it can’t find any more posts with the missing meta key)

  • This is what I’ve been looking for; a way of taking the user to the tab where a required field is blank. But where do I insert the codes?

    Thanks.

    Martin

  • You can’t use form.serialize to upload files. You need to use a formData object.

    https://stackoverflow.com/questions/4545081/how-to-do-file-upload-using-jquery-serialization

  • Hi !
    I needed exactly the same thing, thanks a lot 🙂
    I have a small question about that, it works well when mannualy updating or manually creating a new post but it seems that ‘acf/save_post’ is never fired when posts are added from API.

    Do you have an idea to fire the function even when new content is added from api maybe?

    Regards

  • Hi guys! How are you today?
    I’m having this issue where I can’t send my files to the respective custom post type using ACF Form. I don’t get any erros, all other text based fields works fine, but not this input file part.

    This is my code:

    <?php
        $user_id = get_current_user_id();
        global $post;
        $args = array(
            'post_type' => 'hotels',
            'post_status' => 'publish',
            'posts_per_page' => -1,
            'meta_query'	=> array(
                array(
                    'key'	 	=> 'related_users',
                    'value'	  	=> '"'.$user_id.'"',
                    'compare' 	=> 'LIKE',
                ),
                )
            );
            
        $wp_query = new WP_Query( $args );
        acf_form_head();
        echo '<div data-name="questions" class="dashboard__content">';
        if ( $wp_query->have_posts() ) {
            while ( $wp_query->have_posts() ) {
                $wp_query->the_post();
                
                acf_form(array(
                    'post_id'       => $post->ID,
                    'uploader' => 'basic',
                    'post_content' => false,
                    'updated_message'=> 'Saved',
                    'submit_value'  => __('Update meta'),
                ));
            }
    
        } else { ?>
            <p class="dashboard__error">There's no hotel with this user</p>
            <style>.aside__item:not(#dashboard){display:none;}</style>
        <?php }
        echo '</div>';
    
        wp_reset_postdata();
    ?>

    And this is my Ajax call to send the content to admin:

    $('.acf-form').submit(function (e) {
         e.preventDefault();
         var form = $(this);
         var actionUrl = form.attr('action');
    
         $.ajax({
              type: "POST",
              url: actionUrl,
              data: form.serialize(),
              success: function (data) {
                   $('#message.updated').empty().append('Saved.').css('opacity', '1')
              }
         });
    });
  • @permanyer you are right, a meta query is an array of arrays…

    guess I didn’t copy it but just rewrote it for this and didn’t take the extra array into account.

  • Hello John:

    Thank you for the response, but I would have to argue that you can enter the information such as the fields named Required and Embed Size (width/height). I am trying to get the embed size width and the embed size height.

    Here is a link to the official documentation with a screenshot that has both fields: https://www.advancedcustomfields.com/wp-content/uploads/2014/04/acf-oembed-field-settings.png

    Perhaps I just was not being clear enough? If I can use the get_field_object() function, what are the parameters to get the height/width? I guess I should also figure out how to access the rest of the editable fields as well.

    I appreciate the help.

    –BC

  • I had to replace

    $query->set( 'meta_query', array(
                        'key'       => 'isbn',
                        'value'     => $isbn
                    ) );

    with

    $query->set( 'meta_query', array(
                                                    array(
                                                        'key'       => 'isbn',
                                                        'value'     => $isbn
                                                    )
                                                ) 
                            );

    That is, nesting the array into another array as in docs

  • Load time can be improved in the Admin for WYSIWYG editor fields using delayed or interaction triggered loading via a checkbox when using the Classic WYSIWYG Editor field

    Delay initialisation?
    TinyMCE will not be initialised until field is clicked.

    ACF field speed can be also be improved with local json
    https://www.advancedcustomfields.com/resources/local-json/
    Additionally you may want to explore using Transient caching:

    https://developer.wordpress.org/apis/handbook/transients/
    Hope this information helps your site performance.

  • No, it is not possible to do this with a single WP Query.

  • Great! Yes it is confusing at the beginning but with working through it you get a good understanding of how things work – same was it for me. Yes indeed – krazyplugin have a superb support don´t be afraid to reach out to them. They helped me a lot and were very patient even with stupid beginner questions 🙂 Enjoy!

Viewing 25 results - 4,226 through 4,250 (of 21,339 total)