Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Then the next step is the standard WP mantra “deactivate other plugins and switch theme” to see if you can narrow down what is incompatible. It probably has something to do with another plugin that also uses a jQuery date field.

  • Ok, so I solved this myself. Not in a beautiful way, but it works. I have 12 if functions to check which item(s) the design includes, like <?php if (get_the_title($design->ID) == "1001"){ do something } ?>

    If you have a shorter solution, I’m open to change the code!
    🙂

  • Hi,
    i found the soluce :

    
    $the_query_map = new WP_Query( array( 'post_type' => 'vignerons', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    
    if($the_query_map->have_posts()) :
    while($the_query_map->have_posts()):
    $the_query_map->the_post();
    $the_ID = get_the_ID();
    $link_vignerons = get_the_permalink();
    $get_google_map = get_field('carte', $value);
    $title_vignerons = get_the_title();
    
    $output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'" 
    <h4><a href="'.$link_vignerons.'" rel="bookmark"> '.$title_vignerons.'</a></h4></div>';
    endwhile; endif;
    wp_reset_postdata();
    
    ?><div class="acf-map"><?php
    foreach( $output_map as $key => $map_marker ):
    	echo $map_marker['map'];
    	endforeach;
    	?>
    </div>
    

    Hope this help someone!

  • Hi,

    I found this code and I adapted it to my needs, it works! How to add a link to the single.php of each person who appears on the map?

    $the_query_map = new WP_Query( array( 'post_type' => 'vignerons', 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ) );
    
    if($the_query_map->have_posts()) :
    while($the_query_map->have_posts()):
    $the_query_map->the_post();
    $the_ID = get_the_ID();
    $link_vignerons = get_the_permalink();
    $get_google_map = get_field('carte', $value);
    
    $output_map[$the_ID]['map'] = '<div class="marker" data-lat="'.$get_google_map['lat'].'" data-lng="'.$get_google_map['lng'].'"></div>';
    
    endwhile; endif;
    wp_reset_postdata();
    
    ?><div class="acf-map"><?php
    foreach( $output_map as $key => $map_marker ):
    	echo $map_marker['map'];
    	endforeach;
    	?>
    </div>

    Thanks for help!

  • hello,
    Use the Advanced Custom Fields plugin to take full control of your WordPress edit screens & custom field data.

    Add fields on demand. Our field builder allows you to quickly and easily add fields to WP edit screens with only the click of a few buttons!

    Add them anywhere. Fields can be added all over WP including posts, users, taxonomy terms, media, comments and even custom options pages!

    Show them everywhere. Load and display your custom field values in any theme template file with our hassle free developer friendly functions!

    read more at-https :/ /wordpress .org/plugins/advanced-custom-fields
    TextNow Free Download Photomath Free Download Tutuapp

  • This reply has been marked as private.
  • Solved this, jQuery issue.

  • I have tried many things but none works except of this 🙂

        global $wpdb;
    
        $qry =  "SELECT post_excerpt as 'field_name', post_name as 'field_key' FROM <code>wp_posts</code> where post_type = 'acf-field'";
    
        $results = $wpdb->get_results( $qry, ARRAY_A );

    Wrap it in a function in the functions.php file.

    Hope this works

  • Hi John.
    I use a plugin called Content Crawler that copy products from other stores and publish it on my site. There’re many options, for example how to get titles, content, images, etc, and one of this options is to add post meta key, that I’m using with the ACF plugin. My problem is that some fields are only displayed when I save and publish the post, but no if I publish directly after crawling. For example:

    Example 1: Select field called “games” is displayed if the post is published directly with this code:

    <?php
    if( get_field('games') == 'option1' ): ?>
    	<a href="https://www.site.com/games/option1/">Option 1</a>
    <?php endif; ?>

    Example 2: Select field called “company” isn’t displayed if the post is published directly with this code:

    <?php 
    $field = get_field_object('company');
    $value = get_field('company');
    $label = $field['choices'][ $value ];
    echo $label;
     ?>

    Example 3: Text field called “source” isn’t displayed if the post is published directly with this code:
    <?php echo the_field('sources'); ?>

    In summary, I have draft products created with a crawling plugin that contains meta-keys, and this meta-keys are only displayed when I open each draft product one by one and publish it, If I publish directly without open it or select multiple draft products and I the bulk option to publish it, the fields aren’t displayed. I hope this explanation will be more understandable, sorry for my bad English.

  • 
    <?php 
    	if ( get_field( 'other_information_check' ) && get_field( 'products_specs_check' )): // both checked
    		echo "4-tabs";
    	elseif ( get_field( 'products_specs_check' ) || get_field( 'other_information_check' ) ): // one or the other is checked, but not both
    		echo "3-tabs";
    	else: // no fields checked
    		echo "2-tabs";
    	endif; 
    ?>
    
  • Yes, that’s an interesting question, this is a big change, will ACF work on another type of map to have an alternative field ?

  • Hi again friends,

    I resolved this with the other hook:

    
    
    add_action('acf/save_post', 'my_save_post', 20);
    function my_save_post($post_id){
    
      if( get_post_type($post_id) == 'animal' ) {
    
        // Get the data from a field
        $new_title = get_field('nome', $post_id);
    
        // Set the post data
        $new_post = array(
            'ID'           => $post_id,
            'post_title'   => $new_title,
        );
    
        // Remove the hook to avoid infinite loop. Please make sure that it has
        // the same priority (20)
        remove_action('acf/save_post', 'my_save_post', 20);
    
        // Update the post
        wp_update_post( $new_post );
    
        // Add the hook back
        add_action('acf/save_post', 'my_save_post', 20);
    
      }
    
    }
    

    But the question is, why the code to insert post don´t work in acf/pre_save_post ???

    Thank´s

  • I’ve reworked this and removed the array for checking if it is marked as an archive, instead, I’ve included an if statement within the loop to check whether each repeater has archive sub_group marked true or false. This has helped me achieve the results I was after.

    Makes more sense that way, though probably not as quick.

    Thanks

  • I figured a way to do this by fumbling my way through the concept of PHP closures.

    I created a pull request which you can see here.

  • The problem is that the values are stored in the wrong place, associated with a post instead of a term. Because WPAI was used for the import the fields have the correct key associations. So the first reply, while it can cause issues is not really the problem.

    What you would need to do to correct the situation using the data as it exists.

    1) Get all of the products
    2) Figure out what product category these values were supposed to be applied to
    3) Get these fields from the product
    4) update the field using the correct term id "term_{$term->term_id}"

    The problem here is going to be figuring out #2.
    – What categories is the product assigned to?
    – Is there more than one category?
    – Where the values imported to posts more than one time, i.e. where the same values added to multiple posts in the category?
    – If the product is in multiple categories then which category were the values really meant for?

    Because of these questions, and the additional questions that the answers would probably create, it’s really hard to give any meaningful way to resolve the problem.

    If this was me I would create a field group for the categories and then I’d create to proper import to import these meta values to the categories and I would just ignore the data that was created in the wrong way…. or find an way to just delete it all from the database, rather than try to transform the data that is stored improperly.

  • Thanks for your response John. I’d like to keep the form visible to all so people know what is required without logging in. Is it possible to prevent in the back end?

    As an aside, I’m trying to use the plugin Login with Ajax to activate the form submit button once the user logs in (without page refresh).

  • Is it possible to fix if with update_meta ?
    Support’s answers about problem:

    This is a common occurrence when fields are imported from an external source to the database. The issue occurs because imported field values lack a field reference to format the value of the field so that it can properly load on the admin UI. To fix this, you will need to pass the values through the update_field() function. Please take a look at the following resource page for more info on this: https://www.advancedcustomfields.com/resources/update_field/

    and

    ACF saves term data using a post id parameter containing the string ‘term_’ and thus you will need to ensure that you factor this in while coming up the code. Please note that our support scope does not extend to the provision of custom code snippets but it looks like you are on the right track. I would suggest that you debug your code line by line to ensure that it is returning the expected data. Please take a look at our debugging tutorial on this page: https://www.advancedcustomfields.com/resources/debug/

  • If the field group did not exist before the import then you can’t make these fields appear by creating a new field group.

    And it appears that the fields were not imported to the taxonomy/terms but were imported to the posts. This is why the values do not appear when editing the product category. Since these values are not associated with the term you cannot make them appear in the admin. Quite honestly, I don’t know how they are appearing in the front end.

    Importing into a term is a special process http://www.wpallimport.com/documentation/taxonomies/import-taxonomy-meta/

    in your code

    
    global $woocommerce, $woocommerce_loop, $product;
    $category = get_queried_object();
    $ct = $category->name;
    $catid = $category->term_id;
    the_field('description', $catid); ?>
    

    the value of $catid is wrong. In order to get a value from a field for the term it would need to be the_field('description', 'term_'.$catid); so what you are actually seeing on the front end is the values in post meta that are related to a post with the ID that is equal to whatever that the ID of the term is.

    There really isn’t an easy solution to this if there is a solution at all. If there is I can’t think of one.

  • Hi John,

    I’ve progressed this slightly.

    It’s iterating through and adding the column titles to 7 repeater rows. So that works.

    The update_sub_repeater is adding data to all 7 child repeater fields but it’s counting up for some reason… it’s adding 2 child repeater rows to the first parent repeater, 3 to the second, 4 to the third and so on.

    It’s so close apart from this final part, where am I going wrong?

    // Product Code Titles
    $contents = $html->find('div[class=product-table]', 0);
    $data = array();
    $subdata = array();
    $rows = $contents->find('tr');
    $counter = 0;
    $field_key = "field_5ae0882f9d6f9";
    $sub_field_key = "field_5ae088999d6fb";
    $cellcount = 0;
    foreach ($rows as $key_row => $row) {
    
        if($counter == 0) {
    
          foreach ($row->find('td') as $key_cell => $cell) {
    
            $data[] = array(
              "column_title" => strip_tags($cell->innertext),
            );
          }
    
        } elseif($counter >= 1) {
    
          foreach ($row->find('td') as $key_cell => $cell) {
    
            $subdata[] = array(
              "text" => strip_tags($cell->innertext),
            );
            update_sub_field( array($field_key, $cellcount, $sub_field_key), $subdata, $post_id );        
            $cellcount++;
          }
    
        }
    
    $counter++;
    }
    
    echo $cellcount;
    update_field( $field_key, $data, $post_id );
  • I made it work! Only when I put on the head the restriction. However, I noticed that when saving, the page goes blank and does not load. I think it’s a matter of configuration. Another question is if it is possible for me to play the edit of the fields on a fakepage. Ex:

      site / cpt / post-name / edit will the fields appear without problems, being the same url linked?

  • I made it work! Only when I put on the head the restriction. However, I noticed that when saving, the page goes blank and does not load. I think it’s a matter of configuration. Another question is if it is possible for me to play the edit of the fields on a fakepage. Ex:

      site / cpt / post-name / edit will the fields appear without problems, being the same url linked?

  • Thank you..at first it didnt work,after i googled,i found i missing <php code
    here

    <?php if( get_field('server_1') ): ?>
    <button class="button" type="button" onClick="document.getElementById('frame').src='<?php the_field('server_1'); ?>'">Openload</button>
    <center><iframe name="frame" id="frame" src="<?php the_field('server_1'); ?>" width="640" height="360" scrolling="no" frameborder="0"></iframe></center>
    <?php endif; ?>
  • Ah, I understand the reason for what you’re doing with the template pare. There is a way to do this in WP, but it’s complicated.

    The main issue with post loops nested multiple levels is that after the first nesting things go south if you try to use wp_reset_postdata().

    This explanation is for anyone that comes across this in the future as well because it is a very common misunderstanding about how wp_reset_postdata() or even wp_reset_query() works.

    Basically

    
    // lets say that this is the main WP loop
    while(have_posts()) {
      the_post(); // this is the post that wp_reset_post_data() will reset to
      // now you do another query and you have another loop
      if ($nested_query->have_posts()) {
        while($nested_query->have_posts()) {
          $nested_query->the_post();
          // then if you have a 3rd nesting, for example an ACF relationship field
          $related = get_field('relationship_field'));
          foreach ($related as $post) {
            setup_postdata($post);
            
            // do stuff
            
            // resetting post data here completely screws up the nested query loop
            // instead of resetting to the post of the nested loop
            // it resets to the post of the main loop
            wp_reset_postdata();
          }
        } // end while nested posts
        wp_reset_postdata(); // this works correctly
      } // end if nested posts
    } // end main while
    

    rather than using setup_postdata() and wp_reset_postdata() in the 3rd (and beyond) nesting you need to manage these another way and not mess with the global $post value. For example when you say

    I got the Id’s a different way (got the whole object and then used $object->ID)

  • 
    if (get_field('server_1')) {
    ?>
    <button class="button" type="button" onClick="document.getElementById('frame').src='<?php the_field('server_1'); ?>'">Openload</button>
    <center><iframe name="frame" id="frame" src="<?php the_field('server_1'); ?>" width="640" height="360" scrolling="no" frameborder="0"></iframe></center>
    <?php 
    }
    
  • This is what I tried:

    // Product Code Titles
    $contents = $html->find('div[class=product-table]', 0);
    $data = array();
    $subdata = array();
    $rows = $contents->find('tr');
    $counter = 1;
    $field_key = "field_5ae0882f9d6f9";
    $sub_field_key = "field_5ae088999d6fb";
    
    foreach ($rows as $key_row => $row) {
    
          foreach ($row->find('td') as $key_cell => $cell) {
    
            $data[] = array(
              // element for row
              array(
                // field in parent repeater
                'field_5ae0887c9d6fa' => strip_tags($cell->innertext),
    
                // nested repeater
                $sub_field_key => array(
                  // element for row in nested repeater
                  array(
                    // field in nested repeater
                    'field_5ae088b79d6fc' => "Test",
                  )
                )
              )
            );
    
          }
    
        $counter++;
    }
    update_field( $field_key, $data, $post_id );

    It’s still not adding the sub repeater fields with “Test”.

    I got closer trying this, it added the titles to 7 rows in the parent repeater field (which is correct) but then it added 7 child repeater rows to the 2nd, 3rd and 4th parent repeater with no data in them.

    It’s not quite right as I wanted it to add 7 rows of data to the child repeaters of each parent repeater with the data in them.

    Therefore building up the table in the image, with the column titles in a parent repeater field and the data in the columns as child repeater rows.

    // Product Code Titles
    $contents = $html->find('div[class=product-table]', 0);
    $data = array();
    $subdata = array();
    $rows = $contents->find('tr');
    $counter = 1;
    $field_key = "field_5ae0882f9d6f9";
    $sub_field_key = "field_5ae088999d6fb";
    
    foreach ($rows as $key_row => $row) {
    
        if($counter == 1) {
    
          foreach ($row->find('td') as $key_cell => $cell) {
    
            $data[] = array(
              "column_title" => strip_tags($cell->innertext),
            );
    
          }
    
        } elseif($counter >= 2) {
    
          foreach ($row->find('td') as $key_cell => $cell) {
    
            $subdata[] = array(
              "text" => strip_tags($cell->innertext),
            );
            add_sub_row( array($field_key, $counter, $sub_field_key), $subdata, $post_id );
          }
          
        }
    
        $counter++;
    }
    update_field( $field_key, $data, $post_id );
Viewing 25 results - 9,501 through 9,525 (of 21,340 total)