Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • I was having the same issue because I am using cloned field groups quite heavily. But I discovered a work around.

    1. Set the Collapsed field value in the Repeater to your cloned field.
    2. In your cloned field group add the class “-collapsed-target” to the field you want to show when the repeater is collapsed.
    3. Enjoy.

    Also, if you have multiple fields per row, one (or more) of which you want to display when the repeater is collapsed, add the “-collapsed-target” class to ALL the fields you want displayed. Just make sure they don’t add up to more than 100% width. I do this with a Person repeater where I show the First Name and Last Name when the repeater is collapsed.

    This is definitely a hack, but for now it works.

  • Hello @m-civita

    Rather than create a new custom title, and attempt to associate it with the WP Title in some way, would you rather just move the WP Title to a different spot amongst your ACF fields? Otherwise the rabbit hole can get very deep. For example, you might then need to alter how your lists of Posts are displayed in the Admin, etc.

    I have ran into scenarios where the Post Title would be handy to use still, but being at the top of the page, it wasn’t within the proper flow for data entry. If that’s the case for you as well, below are the steps to go about moving the WP Title to a different location.

    This link has an example of how to move the Content Editor, and the process is very similar for that of the Title.

    STEP 1: The first step is to create a Placeholder Field for the Title. Use the Message field type with default settings for that.

    See the screenshot below for an example in practice. I moved the WP Title, and used it as “Job Name” within a “Projects” Custom Post Type.

    https://imgur.com/6AOwTqW

    STEP 2: The next thing you will need to do is locate the “Field Key” for the Message Placeholder Field from Step 1. The simplest way to do that is:

    a) Go to the ‘Edit Field Group’ screen where that field is located.

    b) Click ‘Screen Options’ at the top of the page, and put a check next to ‘Field Keys’ if it isn’t already checked. You will then see a new ‘Key’ column in your list of fields.

    c) Copy the Field Key, but only the portion after field_ (see the screenshot below)

    https://imgur.com/du7faLq

    STEP 3: Now, you will need to include some custom code. I generally create custom plugins for this. A very simple way to create a custom plugin is by using the free plugin Pluginception.

    Below is sample code to move the Title.

    You will need to replace XXXXXXXXXXXXX with the value you copied from Step 2c above.

    In addition, the following line may not be necessary in your situation. I wanted to make the title a required field, so I included it. If you choose to keep the line, additional code will be required, which I will display below.

    $('.acf-field-XXXXXXXXXXXXX .acf-label > label').append(' <span class="acf-required">*</span>');

    Also, the second style ( namely: .acf-field-XXXXXXXXXXXXX #titlediv #title ) that I added in the code below is optional. I included it because the WP Title text box by default has different styles than the ACF text boxes.

    Include this code within your custom plugin or functions file:

    <?php
    /* START: Moves the WP Title text box to a more appropriate place when adding/editing Projects */
    function cc_move_wp_title_for_projects() {
    ?>
    <script type="text/javascript">
      (function($) {
        $(document).ready(function(){
          $('.acf-field-XXXXXXXXXXXXX .acf-input').append( $('#titlediv') );
          $('.acf-field-XXXXXXXXXXXXX .acf-label > label').append(' <span class="acf-required">*</span>');
        });
      })(jQuery);
    </script>
    <style type="text/css">
      .acf-field #wp-content-editor-tools {
        background: transparent;
        padding-top: 0;
      }
      .acf-field-XXXXXXXXXXXXX #titlediv #title {
        height: 28px!important;
        font-size: 14px!important;
        line-height: 1.4!important;
        padding: 3px 5px!important;
        margin: 0!important;
      }
    </style>
    <?php
    }
    add_action('acf/input/admin_head', 'cc_move_wp_title_for_projects');
    /* END: Moves the WP Title text box to a more appropriate place when adding/editing Projects */
    ?>

    Optional STEP 4: Now, if you decided to keep the line in the code above to make the title a “required” field, below is some more code to use within your custom plugin or functions file.

    Initially, you will want to alter the following lines to match the post type(s) you are working with:

      $post_types = array(
        'projects',
        'customers'
      );

    If just using regular posts for example, you can use:

      $post_types = array(
        'post'
      );

    Finally, here is the code… keeping in mind the changes for post types, described above…

    <?php
    /* START: Require Post Title (i.e. Job Name) for Projects */
    function cc_require_post_title( $post )  {
      $post_types = array(
        'projects',
        'customers'
      );
      if ( ! in_array( $post->post_type, $post_types ) ) {
        return;
      }
    ?>
    <script type='text/javascript'>
      ( function ( $ ) {
        $( document ).ready( function () {
          $( 'body' ).on( 'submit.edit-post', '#post', function () {
            if ( $( "#title" ).val().replace( / /g, '' ).length === 0 ) {
              if ( !$( "#title-required-msj" ).length ) {
                $( "#titlewrap" )
                .append( '<div id="title-required-msj"><em>Field is required.</em></div>' )
                .css({
                  "padding": "5px",
                  "margin": "5px 0",
                  "background": "#ffebe8",
                  "border": "1px solid #c00"
                });
              }
              $( '#major-publishing-actions .spinner' ).hide();
              $( '#major-publishing-actions' ).find( ':button, :submit, a.submitdelete, #post-preview' ).removeClass( 'disabled' );
              $( "#title" ).focus();
              return false;
            }
          });
        });
      }( jQuery ) );
    </script>
    <?php
    }
    add_action( 'edit_form_advanced', 'cc_require_post_title' );
    /* END: Require Post Title (i.e. Job Name) for Projects */
    ?>

    Optional STEP 5: Another optional step is to replace the placeholder text for this field. Remember, by default, WordPress uses the Placeholder: Enter Title Here

    The example below shows how to Blank it out, but you can change the text to whatever you like. Also, you can make certain that it is only for specific post types. As you can see in the example, I am blanking out the Placeholder text for both the ‘customers’ and ‘projects’ post types.

    <?php
    /* START: Blanks the 'Enter title here' text when adding Customers/Projects */
    function cc_change_title_text_for_cpts($title) {
      $screen = get_current_screen();
      if ('customers' == $screen->post_type || 'projects' == $screen->post_type) {
        $title = '';
      }
      return $title;
    }
    add_filter( 'enter_title_here', 'cc_change_title_text_for_cpts' );
    /* END: Blanks the 'Enter title here' text when adding Customers/Projects */
    ?>

    I hope this was helpful for you. I know that it isn’t precisely what you were asking. I will subscribe to this thread and get email alerts if you need further help. But, if it works for you, please let me know!

  • Hi @alekspvn

    I’m not sure I am 100% clear on what is being asked, but I am going to do my best to help. I may need more clarification.

    The Image field can return an Array, a URL, or an ID for each image, so it largely depends on which choice you made as the Return Value how you write the code.

    Since Array is the default return value, I will show code for that below:

    I am guessing you need help with the code between the ‘div’ with the ‘panel’ and ‘multiple-items’ classes, so here goes…

    
    <?php
    if ( have_rows('photo_slider') ) {
      while ( have_rows('photo_slider') ) {
        the_row();
        $slide_photo = get_sub_field('add_photo');
        if ( !empty($slide_photo) ) {
    ?>
    <img src="<?php echo $slide_photo['url']; ?>" alt="<?php echo $slide_photo['alt']; ?>" />
    <?php
        }
      }
    }
    ?>
    

    Is that what you are looking to achieve? I will get an email alert with your reply, and will help further if need be!

  • Hi Ben,

    I was unable to duplicate the issue you are having. I was able to successfully use your filter verbatim when my field was and wasn’t a subfield in a repeater.

    However, the filter: acf/fields/post_object/query is meant for the Post Object type, not the Page Link type. So… it shouldn’t have worked at all for you, subfield or not, if using a Page Link field, right?

    Are you able to switch to a Post Object instead without having to change too much else around?

  • Most page navigation function only work with the main query and not with sub queries.

    You’ve either go to look at the query results and build this navigation yourself or you need to hack the global $wp_query https://wordpress.stackexchange.com/questions/77661/the-next-posts-link-works-only-with-original-wp-query

  • Hi! I tried adding the navigation links using pagenavi and found something interesting: even though I have enough posts to create two archive pages, WordPress is only pulling the first. Theoretically I could have more than the 9 posts per page in the query, but WP would still not show the pagination for the pages after the first.

    How could I fix this?

  • Thanks so much for your help! In the end I was able to do it by calling the default date and permalinks instead of adding a separate custom field for those.

    The result can be seen at http://nerdfit.com/videos

    The only problem I have now is that I can’t get pagination going with this custom post type archive. Is there any way I can show the “older entries” and “newer entries” links at the bottom of the loop?

    This is my code so far:

    <div class="wrap">
    
    	<?php 
    
    	$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;		
    
    	$args = array( 
    		'post_type' => 'video',
    		'paged' => $paged,
    		'posts_per_page' => 9);
    
    	$query = new WP_Query( $args ); ?>
    
    	<?php if ( $query->have_posts()) : while ( $query->have_posts() ) : $query->the_post(); ?>
    
    			<div class="video-item">
    				<div class="video-image">	
    						<a href="<?php echo get_permalink(); ?>" ><?php the_post_thumbnail(); ?></a>
    
    				</div>
    			<h2><a href ="<?php echo get_permalink(); ?>" ><?php the_title(); ?></a></h2>
    			<h3><?php echo get_the_date(); ?></h3>
    
    			</div>
    		
    	<?php endwhile; ?>
    
    <?php
    
    // get_next_posts_link() usage with max_num_pages
    echo get_next_posts_link( 'Older Entries', $the_query->max_num_pages );
    echo get_previous_posts_link( 'Newer Entries' );
    ?>
    
    <?php 
    // clean up after the query and pagination
    wp_reset_postdata(); 
    ?>	
    
    <?php else: ?>
    
    	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    
    	<?php endif; ?>
    
    </div>
    
    </section>
  • sorry for the long delay, you’re reply got burried. Anyway, the post id should already be set up by this

    
    $post_object = get_field('select_sidebar');
    
    if( $post_object ): 
    
    	// override $post
    	$post = $post_object; // this set up the post data including the ID
    	setup_postdata( $post ); 
    
    	?>
        <div class="col-xs-12 col-sm-4 sidebar">
    
    <?php if( have_rows('sidebar_blocks') ): ?>
    

    If this is not working then I’m not sure what the problem is. It could be that the global $post is not defined. Try defining it by adding

    
    global $post;
    

    before $post = $post_object;

  • I found this tutorial. What I want to accomplish is similar to the example 4, but instead of a text field in each row I have a checkbox.

  • I think you may have misunderstood what I was saying to do. When something is selected in the select field you insert, trigger the tab link

    
    $('a.acf-tab-button[data-key="field_59a94850d7bea"]').trigger('click');
    

    and let ACF do the work of showing and hiding all the right fields.

  • This is my current code:

    if( have_rows('cast') ):
       while ( have_rows('cast') ) :
          the_row();
    
             $cast_object = get_sub_field('actor_actress');
             if ( $cast_object) {
                $terms = get_object_terms($cast_object->ID, 'cast_crew_category', array('fields' => 'ids'));
                $thumbid = get_post_thumbnail_id($cast_object->ID);
                $thumb = wp_get_attachment_image_src( $thumbid, 'thumbnail' );
                $url = $thumb['0'];
                $role = get_sub_field('role');
    
                if (in_array('83', $terms)) {
                   echo $role; ?>
                   <a href="<?php echo get_permalink($cast_object->ID); ?>" rel="lightbox" data-lightbox-type="iframe"><img src="<?php echo $url; ?>" width="100%" height="auto"></a>
                   <a href="<?php echo get_permalink($cast_object->ID); ?>" rel="lightbox" data-lightbox-type="iframe"><?php echo $cast_object->post_title; ?></a>
                <?php }
             }
       endwhile;
    endif;
  • I can see how the tabs toggle to active with the class “active” added to the <li>.

    I also see that clicking the tabs toggle visibility on items in the tabs by adding or removing the “hidden-by-tab” class.

    So far, so good. What I don’t see right away is how ACF identifies which fields are associated with a given tab. So I can create the dropdown selector which would trigger the event and I could manually add the field names (e.g. acf-field-599a68e5b5919) or the data-name attribute (e.g. address_1).

    But how can I programmatically distinguish and select the divs for the different tabs?

    It’s a bit of a challenge to climb through the jQuery code, could you provide a sample of how the plugin does it, so I (and others with this challenge in the future) can have a roadmap to implementing such a solution? Happy to post my code when I get a final working version.

    Thanks!

  • I’m looking at something like this now. I have a user registration form that has custom ACF questions that get put into the user profile, but how do we access that specifically?

    For me, I get the start beside the radio buttons on the form, the format has come out perfect, I just don’t know how to access them.

  • Thanks for reply maira,
    Yes the field name is $foto. but its not working.
    Actually i want to add a label on the Product category images like this
    http://prntscr.com/gefwfd

    I have set the setting below way…

    1. Set file name $foto

    2. Return Value set to Image URL http://prntscr.com/geft8t

    3. set rule, Taxonomy Term -> is equal to -> Product Categories
    http://prntscr.com/gefrjw

    4. The Image showing ok on the product category fields http://prntscr.com/geg1s2

    5. added your code to functions.php

    if ( is_product_category() ) {
    // vars
    $queried_object = get_queried_object();
    $taxonomy = $queried_object->taxonomy;
    $term_id = $queried_object->term_id;
    $foto = get_field( 'foto', $queried_object );
    $foto = get_field( 'foto', $taxonomy . '_' . $term_id );
    if( get_field('foto', $taxonomy . '_' . $term_id) ) {
    echo '<div class="cat-banner"></div>';
    }
    }

    i am a newbee, Sorry for bothering you. Would you like to suggest me what else need to do.

    Thanks in advance

  • @updownupdown Hi, once you add code for google maps for acf, you need to input the coordinates of polygon:

    // center map
    	center_map( map );
    
    	// Define the LatLng coordinates for the polygon.
    	var triangleCoords = [
    		{lat: 44.28223, lng: 20.63992},
    		{lat: 44.28253, lng: 20.63935},
    		{lat: 44.28301, lng: 20.63984},
    		{lat: 44.28226, lng: 20.64103},
    		{lat: 44.28246, lng: 20.64138},
    		{lat: 44.28192, lng: 20.64267},
    		{lat: 44.2812, lng: 20.64186},
    		{lat: 44.28206, lng: 20.63973}
    	];
    
    	  // Construct the polygon.
    	  var bermudaTriangle = new google.maps.Polygon({
    	  	paths: triangleCoords,
    	  	strokeColor: '#FF0000',
    	  	strokeOpacity: 0.8,
    	  	strokeWeight: 3,
    	  	fillColor: '#FF0000',
    	  	fillOpacity: 0.35
    	  });
    	  bermudaTriangle.setMap(map);
    
    	  // Add a listener for the click event.
    	  bermudaTriangle.addListener('click', showArrays);
    
    	  infoWindow = new google.maps.InfoWindow;
    // }
    

    after that you can render the polygon with this piece of code:

    /** @this {google.maps.Polygon} */
    function showArrays(event) {
      // Since this polygon has only one path, we can call getPath() to return the
      // MVCArray of LatLngs.
      var vertices = this.getPath();
    
      var contentString = '<b>Bermuda Triangle polygon</b><br>' +
          'Clicked location: <br>' + event.latLng.lat() + ',' + event.latLng.lng() +
          '<br>';
    
      // Iterate over the vertices.
      for (var i =0; i < vertices.getLength(); i++) {
        var xy = vertices.getAt(i);
        contentString += '<br>' + 'Coordinate ' + i + ':<br>' + xy.lat() + ',' +
            xy.lng();
      }
    
      // // Replace the info window's content and position.
      // Turned off since i didn't need the rendering of tooltip over polygon.
      // infoWindow.setContent(contentString);
      // infoWindow.setPosition(event.latLng);
    
      // infoWindow.open(map);
    }
    	

    And that is it 🙂

    Here is the code i use for google maps on one of the wp website where i needed polygon area:

    <style type="text/css">
    
    .acf-map {
    	width: 100%;
    	height: 400px;
    	border: #ccc solid 1px;
    	/* margin: 20px 0; */
    }
    
    /* fixes potential theme css conflict */
    .acf-map img {
       max-width: inherit !important;
    }
    
    </style>
    <script src="https://maps.googleapis.com/maps/api/js?key=ADD-YOUR-KEY-HERE"></script>
    <script type="text/javascript">
    (function($) {
    
    /*
    *  new_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 new_map( $el ) {
    	
    	// var
    	var $markers = $el.find('.marker');
    	
    	
    	// vars
           //custom styling of the map
    	var args = {
    		zoom		: 16,
    		center		: new google.maps.LatLng(0, 0),
    		
    		styles: [
    				{
    					"featureType": "all",
    					"elementType": "geometry",
    					"stylers": [
    						{
    							"color": "#574029"
    						}
    					]
    				},
    				{
    					"featureType": "all",
    					"elementType": "labels.text.fill",
    					"stylers": [
    						{
    							"gamma": "1.27"
    						},
    						{
    							"lightness": 20
    						},
    						{
    							"color": "#ffffff"
    						}
    					]
    				},
    				{
    					"featureType": "all",
    					"elementType": "labels.text.stroke",
    					"stylers": [
    						{
    							"saturation": "-100"
    						},
    						{
    							"lightness": "-100"
    						},
    						{
    							"weight": "1.19"
    						},
    						{
    							"gamma": "0.00"
    						},
    						{
    							"hue": "#ff0000"
    						},
    						{
    							"invert_lightness": true
    						}
    					]
    				},
    				{
    					"featureType": "all",
    					"elementType": "labels.icon",
    					"stylers": [
    						{
    							"visibility": "off"
    						},
    						{
    							"saturation": "-100"
    						},
    						{
    							"lightness": "-100"
    						},
    						{
    							"gamma": "0.00"
    						},
    						{
    							"weight": "0.01"
    						}
    					]
    				},
    				{
    					"featureType": "landscape",
    					"elementType": "geometry",
    					"stylers": [
    						{
    							"lightness": 30
    						},
    						{
    							"saturation": 30
    						},
    						{
    							"color": "#919d8b"
    						}
    					]
    				},
    				{
    					"featureType": "poi",
    					"elementType": "geometry",
    					"stylers": [
    						{
    							"saturation": 20
    						}
    					]
    				},
    				{
    					"featureType": "poi.park",
    					"elementType": "geometry",
    					"stylers": [
    						{
    							"lightness": 20
    						},
    						{
    							"saturation": -20
    						}
    					]
    				},
    				{
    					"featureType": "road",
    					"elementType": "geometry",
    					"stylers": [
    						{
    							"lightness": "40"
    						},
    						{
    							"saturation": -30
    						}
    					]
    				},
    				{
    					"featureType": "road",
    					"elementType": "geometry.stroke",
    					"stylers": [
    						{
    							"saturation": 25
    						},
    						{
    							"lightness": "100"
    						},
    						{
    							"gamma": "1.00"
    						},
    						{
    							"weight": "0.78"
    						}
    					]
    				},
    				{
    					"featureType": "water",
    					"elementType": "all",
    					"stylers": [
    						{
    							"lightness": -20
    						}
    					]
    				}
    			],
    		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 );
    
    	// Define the LatLng coordinates for the polygon.
    	var triangleCoords = [
    		{lat: 44.28223, lng: 20.63992},
    		{lat: 44.28253, lng: 20.63935},
    		{lat: 44.28301, lng: 20.63984},
    		{lat: 44.28226, lng: 20.64103},
    		{lat: 44.28246, lng: 20.64138},
    		{lat: 44.28192, lng: 20.64267},
    		{lat: 44.2812, lng: 20.64186},
    		{lat: 44.28206, lng: 20.63973}
    	];
    
    	  // Construct the polygon.
    	  var bermudaTriangle = new google.maps.Polygon({
    	  	paths: triangleCoords,
    	  	strokeColor: '#FF0000',
    	  	strokeOpacity: 0.8,
    	  	strokeWeight: 3,
    	  	fillColor: '#FF0000',
    	  	fillOpacity: 0.35
    	  });
    	  bermudaTriangle.setMap(map);
    
    	  // Add a listener for the click event.
    	  bermudaTriangle.addListener('click', showArrays);
    
    	  infoWindow = new google.maps.InfoWindow;
    // }
    
    	
    	// return
    	return 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
    	icon = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png';
    	var marker = new google.maps.Marker({
    		position	: latlng,
    		icon        : icon,
    		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( 16 );
    	}
    	else
    	{
    		// fit to bounds
    		map.fitBounds( bounds );
    	}
    
    }
    
    /** @this {google.maps.Polygon} */
    
    function showArrays(event) {
      // Since this polygon has only one path, we can call getPath() to return the
      // MVCArray of LatLngs.
      var vertices = this.getPath();
    
      var contentString = '<b>Bermuda Triangle polygon</b><br>' +
          'Clicked location: <br>' + event.latLng.lat() + ',' + event.latLng.lng() +
          '<br>';
    
      // Iterate over the vertices.
      for (var i =0; i < vertices.getLength(); i++) {
        var xy = vertices.getAt(i);
        contentString += '<br>' + 'Coordinate ' + i + ':<br>' + xy.lat() + ',' +
            xy.lng();
      }
    
      // // Replace the info window's content and position.
      // Turned off since i didn't need the rendering of tooltip over polygon.
      // infoWindow.setContent(contentString);
      // infoWindow.setPosition(event.latLng);
    
      // infoWindow.open(map);
    }
    
    /*
    *  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
    */
    // global var
    var map = null;
    
    $(document).ready(function(){
    
    	$('.acf-map').each(function(){
    
    		// create map
    		map = new_map( $(this) );
    
    	});
    
    });
    
    })(jQuery);
    </script>

    and i used this polygon render by google as starting point, and of course the pen u mentioned earlier to get the coordinates of the polygon i needed.

  • Thanks for your reply; I got it working like this (using acf/load_field to first check permissions and set a global var):

    add_action ( 'admin_footer', 'check_ACF_permissions_button' );
    
    function check_ACF_permissions_button($post) {
    
    	if ($GLOBALS['projectManager'] === false) {
    
    		?><script type="text/javascript">
    		jQuery('a[data-event="add-row"]').remove();
    		jQuery('a[data-event="remove-row"]').remove();
    		</script><?php
    	
    	}
    }
  • I’ve looked quickly at the free version of the plugin you mentioned and it shows the same problem. I can’t figure out where the conflict is. You’re best chance at getting this fixed is to submit a new support ticket here https://support.advancedcustomfields.com/new-ticket/

  • You are running your code inside of a function. Are your sure that get_the_ID() is returning the correct value in this context?

    
    <?php if ( $query->have_posts()) : while ( $query->have_posts() ) : $query->the_post(); ?>
    
    <div class="video-item">
    <div class="video-image">	
    <?php 
      // see what get_the_ID() is returning
      // make sure it's the same as the image
      echo get_the_ID();
    ?>
    <a href ="<?php echo( get_post_meta( get_the_ID(), 'video_live_url', true))?>" ><?php the_post_thumbnail(); ?></a>
    

    also, you may need to add this line inside of your function, but I’m not sure, it’s just a guess.

    
    global $post
    
  • Thanks for the reply, your suggestion got me digging and found a plugin (Tickera) that was running jQuery.validate() on the ACF fields and because they have a ‘maxlength’ property that is unspecified this was being treated as a maxlength of 0, causing the error. I will talk with that developer about ignoring the ACF fields.

    Thanks for your help!

  • @mediawerk Thanks so much , code is working fine!

    Just one question:

    Is it possible to add an URL to each marker?

  • You need to update ACF. The PHP code you posted in no longer part of ACF4

    
    $this->l10n = array(
     'max'     => __("Maximum values reached ( {max} values )",'acf'),
     'tmpl_li' => '
                   <li>
                     <a href="#" data-post_id="<%= post_id %>"><%= title %><span class="acf-button-remove"></span></a>
                   <input type="hidden" name="<%= name %>[]" value="<%= post_id %>" />
                  </li>
                 '
    );
    
  • Sorry, not 100% sure I follow you. We agree that the code like:

    `post_id=\”<%= post_id %>\”>

    should not be visible, but rather should be parsed – something like:

    post_id=\"45\">

    Meaning an error is occurring before this, and that I’m to check for that error(s)? Just double checking…

  • I couldn’t tell you if this has anything to do with the error or not, but the code you mention is run and you can see the result in part of that JSON string

    ... "relationship":{"max":"Maximum values reached ( {max} values )","tmpl_li":"\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<a href=\"#\" data-post_id=\"<%= post_id %>\"><%= title %><span class=\"acf-button-remove\"><\/span><\/a>\n\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"<%= name %>[]\" value=\"<%= post_id %>\" \/>\n\t\t\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t"} ...

    I would be looking for other JS errors that happen prior to the error in ACF.

  • Thank you John.

    One thing I’ve noticed is that the following embedded php code in relationship.php doesn’t seem to execute/parse:

    $this->l10n = array(
     'max'     => __("Maximum values reached ( {max} values )",'acf'),
     'tmpl_li' => '
                   <li>
                     <a href="#" data-post_id="<%= post_id %>"><%= title %><span class="acf-button-remove"></span></a>
                   <input type="hidden" name="<%= name %>[]" value="<%= post_id %>" />
                  </li>
                 '
    );

    The result when run and viewed (via the chrome console) the result is the following, which still has the literal variables, not the values I would expect:

    	// new vars
    	acf.o = {"post_id":425,"nonce":"25e1faa643","admin_url":"http:\/\/stage.media.foodlandontario.ca\/wp-admin\/","ajaxurl":"http:\/\/stage.media.foodlandontario.ca\/wp-admin\/admin-ajax.php","wp_version":"4.8.1"};
    	acf.l10n = {"core":{"expand_details":"Expand Details","collapse_details":"Collapse Details"},"validation":{"error":"Validation Failed. One or more fields below are required."},"image":{"select":"Select Image","edit":"Edit Image","update":"Update Image","uploadedTo":"uploaded to this post"},"file":{"select":"Select File","edit":"Edit File","update":"Update File","uploadedTo":"uploaded to this post"},"relationship":{"max":"Maximum values reached ( {max} values )","tmpl_li":"\n\t\t\t\t\t\t\t<li>\n\t\t\t\t\t\t\t\t<a href=\"#\" data-post_id=\"<%= post_id %>\"><%= title %><span class=\"acf-button-remove\"><\/span><\/a>\n\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"<%= name %>[]\" value=\"<%= post_id %>\" \/>\n\t\t\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t"},"google_map":{"locating":"Locating","browser_support":"Sorry, this browser does not support geolocation"},"date_picker":{"closeText":"Done","currentText":"Today","monthNames":["January","February","March","April","May","June","July","August","September","October","November","December"],"monthNamesShort":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"monthStatus":"Show a different month","dayNames":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"dayNamesShort":["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],"dayNamesMin":["S","M","T","W","T","F","S"],"isRTL":false}};
    	acf.fields.wysiwyg.toolbars = {"full":{"theme_advanced_buttons1":"bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,aligncenter,alignright,link,unlink,wp_more,spellchecker,fullscreen,wp_adv","theme_advanced_buttons2":"formatselect,underline,alignjustify,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help,code","theme_advanced_buttons3":"","theme_advanced_buttons4":""},"basic":{"theme_advanced_buttons1":"bold,italic,underline,blockquote,strikethrough,bullist,numlist,alignleft,aligncenter,alignright,undo,redo,link,unlink,fullscreen"}};

    Thoughts?

  • Honestly, I can’t say if your query is right or wrong by looking at it. For me, I would back up the database and run it and see what happens. I’m not really an expert on SQL.

Viewing 25 results - 10,776 through 10,800 (of 21,317 total)