Support

Account

Home Forums Search Search Results for 'q'

Search Results for 'q'

reply

  • Another quick somewhat related question. I try uploading files as a logged out user and get an uploading error:
    An error occurred in the upload. Please try again later.

    I’m looking in my PHP console and don’t see any issues and none in my JS console either. Do either of you happen to know what this is about?

    Thanks!

  • You mentioned when you loaded the .php file directly, does this mean this isn’t a part of a WordPress page? A stand-alone PHP page? I’m not sure whether ACF fields would be accessible through this or not, i’d guess not.

    You’d be better off adding a php callback function for your ajax in your functions.php file.

    Here’s a simple example of getting a field with AJAX:

    In your functions.php:

    
    add_action('wp_ajax_getdatefunction', 'getdate'); 
    add_action('wp_ajax_nopriv_getdatefunction', 'getdate'); 
    function getdate(){
    
       the_field('your_date_field');
    
       die();
    }
    

    In your JS file:

    
    $('button').click(function(){
    	$.ajax({
    		type: "POST", 
    		url:'/wp-admin/admin-ajax.php',
    		data: 'action=getdatefunction',
    		cache: true, 
    		success: function(results){
    			$('.your-date-container').html(results);
                            alert('The date is: '+results);
    		}
    	});
    });
    
  • The default setup doesn’t allow required sub-fields in Repeater fields I don’t think. This doesn’t mean to say you can’t come up with your own solution though.

    I’d approach this in either 2 routes:

    1) Create bit of jQuery that sits on the edit pages of WP and doesn’t allow the post to be Published until the required sub-fields are validated.

    2) Simply add conditional code to wherever you are using the sub-fields data to not output the element if the sub-field isn’t populated (I do this often for things like captions or titles in repeater fields)

    If you need help with the first bit of JS let me know as i’ve written something similar for a major project that required custom validation of ACF fields.

  • You’d be looking at a simple bit of jQuery like this (obviously you will have to change the selectors)

    
    currentSlide = $('.slider .active');
    nextSlide = currentSlide.next();
    prevSlide = currentSlide.prev();
    
    /** then to get for instance, a caption from inside the slides : *//
    nextSlideData = nextSlide.find('p.caption').html();
    prevSlideData = prevSlide.find('p.caption').html();
    
    alert('Next caption: '+nextSlideData+' & Previous caption: '+prevSlideData);
    
  • I’m looking into any differences with included scripts on the page but when I use typeof acf I get back "object" so it seems to be getting included properly.

    I’ll update with the scripts that are being included on the page.

    UPDATE: However, when I include jQuery myself (it looks automatically included from acf_form_head(); ) via a normal scrip tag, I get the Uncaught ReferenceError: acf is not defined.

    Very very strange

  • Hi @rafael401

    The relationship field will only be able to save data about a post_id, so unfortunately what you want to do is not possible with this field.

    Essentially, what you are describing is a relationship from a render to a building with metadata on the connection. The metadata states the room in the building.

    I think a solid solution will be to use the posts 2 posts plugin instead of the relationship field.

    It is a very flexible plugin which requires good PHP knowledge, but has good documentation so it’s not too hard to get started with it.

    That plugin will allow you to create these connections with the extra ‘meta’ data on each connection.

    Hope that helps.

  • Hi @harini

    Thanks for the detailed description of the issue.

    I believe the the solution is quite simple, and is the fact that you care using the wrong $post_id parameter to load data from a taxonomy term.

    Please read over this article and pay special attention to the post_id param:

    http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    Your post_id param should be

    'category_' . $category_id

  • Anyone that stumbles across this post in need of help with importing a CSV of posts into WP, try out this plugin. It allows you to add columns for all of the default WP fields like the_title, the_content and so on. It also allows any custom fields to be added as columns, so ACF is completely compatible.

    In fact, you can even stick a repeater field into the CSV. I done this for a recent site.

    You’d have the columns like:
    repeater_0_text, repeater_1_text, repeater_2_text, repeater_3_text

    And then another just called ‘repeater’, with the amount of sub-fields (in this example, the value would be 4).

    Give it a try! Hope this helps someone one day.

    http://wordpress.org/plugins/csv-importer/screenshots/ (I know it’s old, but it works)

  • O.K thanks for the update, will keep an eye out for that feature release.

    Not sure why it was posted as a ‘Post’ as I thought I ticked the question option as your right it’s definitely a questions.

    Cheers
    Heath

  • Hi @evzin

    1. Yes, the multi-site license allows you to use the add-ons in all web projects you work on. You can also incude the add-ons within premium themes, however, this may change in the future with an introduction of a developer license.

    2. Yes, all add-ons will recieve updates

    3. ACF is required for the add-ons to function. Think of it as a limb needs a body to work.

    4. Yes and No. The flexible content field can replicate all of the repeater field functionality except it’s user experience. A client will be much happier using the repeater field to upload images / files at it supports multiple file uploads / quicker to add rows. Also, the code is simpler in the templating.

    5. You may us the message field to add HTML to the options page!

  • Thanks mate,

    I like both the ideas. I’ll have a look at adding these in.

  • Hi @zquintana

    Great work on the code. Would you mind editing that reply and marking it as the topic solution?

    Thanks mate

  • Check the ‘postmeta’ MySQL table (in phpmyadmin, you can search for it by the post_id).

    One thing I would make sure is that your field has a field reference – this will be another postmeta entry with the same meta_key as your field prefixed with an underscore (e.g. if your field name is “my_field” the reference field meta_key would be “_my_field”). The meta_value of the reference field should be something like “field_2342451923sf” – however, if it is like “temp_key_for_my_field”, your field was not saved/created correctly. If you can verify this is not the case, that would be a good first step.

  • @zquintana,
    Nice workaround and thanks for the info on brackets (seems like PHP is borrowing a thing or two from javascript)

  • Even more info!

    1. When the Library for the file is set to “Uploaded to post” the front-end form fails at line 50 of file.js: this.o.query.uploadedTo = acf.o.post_id; with the error Uncaught TypeError: Cannot read property 'post_id' of undefined | input.php:812
    2. When the Library is set to “All” that error is avoided but there is another error that occurs in file.js on line 138 title : acf.l10n.file.select, with the error Uncaught TypeError: Cannot read property 'file' of undefined | input.php: 900

    I’m not sure where to go from here

  • Currently the image and file fields have an option for the lobrary to be restricted to ‘uploaded to’.

    This will soon be added to the gallery field.

    P.S. May I ask why you did not set this topic as a question, but as a post?
    It sounds like a question to me

  • Hi @darkwoods

    I don’t understand the requirements of your data setup. How doe sub category relate to the categories?

    Perhaps you could use nested repeater fields? Each category can have a repeater for a sub category.

  • A few tips:

    In the future, if your topic is a question, please do not mark it as a post. Can you please edit this topic and set it as a question so it can be marked solved once complete.

    I would use the get_posts function which accepts the WP_Query args to find the posts. There are args that allow you to search for custom field values. There is even documentation on the ACF site that talks you through how to query posts based on custom field values.

    On that note, did you not search before posting this question?

  • Will I add a function to allow you to search a repeater field for a specific row value?

    No, this is a bit out of scope for the ACF plugin

    Does this solve your question?

  • Btw square brackets are the new in php5.4 for short notation of array(). If you are using <5.4 then use array().

  • i was able to figure it out. For anyone else wondering…

    
    // To get field groups:
    $fieldgroups = apply_filters('acf/get_field_groups');
    
    // To get rules: 
    $location = apply_filters('acf/field_group/get_location', [], $fieldgroup['id']);
    
    // To get fields of group:
    $groupFields = apply_filters('acf/field_group/get_fields', [], $fieldgroup['id']);
    
  • Values.

    I have a spreadsheet with posts and additional fields (custom fields). I want to import this into WP. Not seeing how to do that.

    Zach

  • I think I have miss0understood your original question due to the language barrier.

    Are you asking how to export / import custom field objects?
    Or are you asking hoe to export / import custom field values?

  • I checked out the dump from the custom fields export. It looks like it stores all the data from the actual value as a PHP serialization. This creates a problem for what I’m trying to do. I need to bulk import from a csv a custom post type that has custom fields. I’m using your custom fields plugin for the fields. I have plugin that used to import fields with your plugin. It seems like the code has been deprecated since then.

    In PHP, how would I get all the fields of a field group along with the rules? Your documentation is very clear on how to do that.

  • Before to buy this add-on, have some questions.

    1. Does the plugin custom fields supports shortcodes?
    2. Can i import custom fields data using bulk import?

    Kindly reply

    with regards
    Selvam.S

Viewing 25 results - 21,301 through 21,325 (of 21,334 total)