Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • It may be that it was read, but that no one has read it that can help you. This is a users helping other users forum.

    The best help that I can offer is to point you to additional documentation, there is a section on this page that covers adding mutliple markers near the end of the page. https://www.advancedcustomfields.com/resources/google-map/

    There is also another post on it here, but it’s quite old so I don’t know if there’s anything in it that would be helpful https://support.advancedcustomfields.com/forums/topic/multiple-post-points-on-google-maps/

  • Hi hi,

    Here’s a simple example of how a addon extends the core field looks like:
    https://gist.github.com/gummiforweb/3293ec7a0f0708df40c2ae5df8252fa3

    Here’s some things I notice so far with the sample field,
    1) When create new field, the field “My Custom Field” do show up in the field type dropdown, but after 5.6, “My Custom Field” doesn’t show up in the dropdown anymore.
    5.5.14: https://www.screencast.com/t/weRD4owkUY
    5.6.0: https://www.screencast.com/t/7BETqEES3

    2) When editing and exiting field in a post, it’s loading repeater’s render_field. (i think this might be true for all the field actions/filters)
    5.5.14: https://www.screencast.com/t/lVliDpia
    5.6.0: https://www.screencast.com/t/YqDTz23RQ

    Right now, a quick fixes on the addon part is to add an empty initialize method like:

    
    public function initialize() {}
    

    🙂

  • I found this thread https://support.advancedcustomfields.com/forums/topic/reverse-query-relationship-subfield-which-is-nested-in-a-repeater-field/

    Here is the specific code that works for me, just in case seeing a specific helps anyone in the future

    
    <?php 
    // custom filter to replace '=' with 'LIKE'
    function my_posts_where( $where )
    {
    		$where = str_replace("meta_key = 'credits_%_credits__person'", "meta_key LIKE 'credits_%_credits__person'", $where);
     
    		return $where;
    }
     
    add_filter('posts_where', 'my_posts_where');
     
    // args
    $args = array(
    		'post_type' => 'work',
    		'meta_query' => array(
    				array(
    						'key' => 'credits_%_credits__person',
    						'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(). ?>
    
  • I made a regular relationship field as a test and the code above for my single-team.php worked, so the challenge is just figuring out how to reverse query the relationship field out of a repeater

  • 
    <?php 
    	$value = get_sub_field('embed_iframe', false);
    if (preg_match('/src="([^"]+)/', $value, $matches)) {
      $url = $matches[1];
    }
    
    echo $url;
    ?>
    
  • Hi John,

    I get no output? Do i something wrong? I have not changed the iframe content in the textarea but i dont get the src value.

    <?php 
    	$value = get_sub_field('embed_iframe', false);
    if (preg_match('/src="([^"]+)/', $value, $matches)) {
      $url = $matches[1];
    } ?>
  • I’m using the following to download the zip file:

    $ wget -O ./acf-pro.zip "http://connect.advancedcustomfields.com/index.php?p=pro&a=download&k=[license key here]"

  • Fields on options pages must have unique field names and field keys. All values are stored in the option table.

  • Yep, it doesn’t happen on all the addon, but i saw a couple ppl asking on github so i thought I’d post it here. The new constructor will only affect addon that extends on the existing core field.

    2 of my addon are extending repeater field. and couple other ones i use that extends image and gallery field all run into the same issue.

    Basically, what happen is, say, you have a addon that extends repeater field, the class look something like this:

    
    class my_custom_field extends acf_field_repeater
    {
        public function __construct()
        {
            $this->name = 'my_custom_field';
            // ... ohter stuff
    
            // not calling on the repeater but the core field
            acf_field::__construct(); 
        }
    }
    

    So, with the new constructor, a field registration’s order will happen like this:

    1. my_custom_field::__construct()
    2. acf_field::__construct()
    3. acf_field_repeater::initialize() <—-

    the 3rd one, because my_custom_field will not have method called ‘initialize’, so it will call the repeater’s initialize() and will cause unexpected error depends on the addon. Because repeater’s initialize() will overwrite the correct $default, $name etc… properties. So, my_custom_field->name is actually “repeater” instead of “my_custom_field”.

    I’m not sure if this is consider a bug, cause it’s more like the addon author need to fix their code 🙂

    There’s actually another cleaner quick fix, which is adding an empty body initialize() method on the my_custom_field class

  •    $('a[href="#directions"]').one('click',function(){
            $('.hotel-map').each(function(){
                // create map
                map = new_map( $(this) );
            });
        });
  • 
    // ...................
      } elseif ($product_id == 1126) {
        $e_post = get_page_by_title( $title );
        $epost_id = $e_post->ID;
        $member = wp_get_current_user();
        $newmember = $member->ID;
        
        $members = get_field('comp_members', $epost_id, false);
        if (!is_array($members)) {
          $members = array();
        }
        $members[] = $newmember;
        
        update_field( 'comp_members', $newmember, $epost_id);
        echo "New Member, $newmember , added to $title.";
    
    } // End of new member
    
  • In that case you would need to use string manipulation functions, or most likely regular expressions. The problem with these is that they may or may not work if the format of the content is altered

    
    $value = get_sub_field('embed_iframe', false));
    if (preg_match('/src="([^"]+)/', $value, $matches)) {
      $url = $matches[1];
    }
    
  • I think you would set 'default_value' => 0. When I have questions like this I generally create a field like the type I want to use for my field with the settings I want it to have and then do an export to code to see that the settings are.

  • Hi,

    I couldn’t find anything on this but it should be quite simple.

    In each post, I am adding all the images in the gallery field.

    Now I would like my authors to be able to insert each image between text using a shortcode like this:

    [mygallery image=”1″]
    [mygallery image=”2″]
    etc…

    Any help would be much appreciated!

  • Hi John,

    It’s not a oEmbed field but a textarea. It’s for placing a Google Map on the site but i want to put the iframe tags around it myself so i only need the url(src) of the iframe.

    Google maps

  • Even if this could be done in some way so that it would work with ACF image fields, there still would not be any way to prevent images being “removed in an over-enthusiastic cleanup.” WP uses the post_parent in the _posts table to mark an image uploaded to a post. WP has no built in mechanism for uploading or adding attachments to any other type of object. This is something that’s not likely to change, I doubt that you’ll ever see a built in WYSIWYG on a term or anywhere else in WP for that matter. Also, the post_parent field requires an integer that is assumed to be another post ID, so anything created would be a work-a-round that would be outside of anything that WP would recognize.

    There is one solution that I just thought of. There is the ability for ACF to save field values of options pages as related to a “post” (see the ‘post_id’ argument https://www.advancedcustomfields.com/resources/acf_add_options_page/) and I think that this will make it work the same, I just tested this and I know it works. The thing here is that you need posts, of some type, to store the values on and this means creating some type of post type for holding the options fields. My plugin that lets you create options pages using an admin interface will also let you save fields to the post of the options page settings… https://wordpress.org/plugins/options-page-admin-for-acf/

  • ACF will need to be installed and active to use your plugin that uses ACF. There are couple ways to handle this. You can tell people that ACF is required or you can install ACF as part of your plugin https://www.advancedcustomfields.com/resources/including-acf-in-a-plugin-theme/

  • Спасибо помогло!

    – make sure the Google Maps Api’s are enabled:
    Google Maps Directions API
    Google Maps Distance Matrix API
    Google Maps Elevation API
    Google Maps Geocoding API
    Google Maps JavaScript API
    Google Places API Web Service
    Google Static Maps API
    – copy the generated API key

  • This reply has been marked as private.
  • This would only work for an ACF taxonomy field and not for the standard WP category meta box.

    I don’t know if you can limit the categories in the WP meta box, after a quick search I found nothing on the subject. The only thing I can find information on is how to hide it.

  • Thanks for the reply @hube2. I’m getting that value from a field in the backend that is a drop-down selector. This selects from a post type called ‘Sidebars’. The idea is that you can create any number of sidebars, add content into them, then add them onto any page from the drop-down. As I mentioned, this works 100% on any standard page outside of Woocommerce.

    In answer to your second question, the example I pasted above is in the generic sidebar.php file which is pulled into all page templates. It’s not wrapped in any kind of post loop.

    Thanks

  • That really depends on how the other plugin adds these elements. I suspect that it will require some custom javascript or css or maybe some modification to the other plugin. In any case the best bet for finding out how to move them would be to ask the support team for that plugin.

  • You can use this filter https://www.advancedcustomfields.com/resources/acf-fields-taxonomy-query/. See get terms arguments here https://developer.wordpress.org/reference/classes/wp_term_query/__construct/. You and use include to only list the ones you want or you can use exclude to eliminate the ones you don’t want.

  • k, so there’s an obvious typo in my code, proof that the brain sees what you expect to see since I missed it at least 4 times. Tell me if you can spot the difference

    
    $args = array(
      'post_type' => 'locations',
      'posts_per_page' => -1
    );
    $query = new WP_Query($args);
    $facebook_ids = array();
    if ($query->have_posts()) {
      while($query->have_posts()) {
        $query->the_post();
        echo get_field('facebook_group_name').'<br />';
        $facebook_ids[] = get_field('facebook_group_name');
      }
      wp_reset_postdata();
    }
    echo implode(',', $facebook_ids);
    
Viewing 25 results - 10,926 through 10,950 (of 21,318 total)