Support

Account

Forum Replies Created

  • Hi,

    I think your issue is that your format is not supported by strtotime.
    Try changing the if to:
    <?php if ( strtotime( $today ) <= strtotime( get_sub_field( 'date', false ) ) ) { ?>
    The second parameter of get_sub_field will return the date unformatted in the way it is saved by ACF (which is Y-m-d H:i:s) and will work with strtotime.

  • Just use what you’re using 🙂
    You can use strip_tags() to avoid tags

  • Hi @donnafefe

    Make sure that you’re actually just getting image ids with this:
    $image_ids = get_field('imggal', false, false);
    Also, does it work with the limit plugin deactivated? Maybe it also limits images to those uploaded to the post.

    In the end it seems more like an issue/bug with the gallery shortcode in WordPress than ACF. If you truly are getting all 6 attachment IDs with the above code ACF is doing it’s part correctly.

  • Hi @robtje

    Great! I’ll be sure to notify elliot so that he changes the documentation properly. I’ve yet to query based on the new time field myself so I trusted the docs blindly 😉

    Best of luck in your project.

  • Okay so it’s an issue of ACF no longer playing nice with preview of a draft post. Even if it’s saved (not just previewed before saved as draft).

    I’ll make an issue on github. Tho since Elliot already responded to the previous post he seems to be on it already 🙂

  • Hi @beee

    There’s some different ways to go about it. Since you’re using the pre_save_post hook you could just as easily change the title acf field value straight in the $_POST.

    You would only need to remove the save_post action hook IF you’re doing a function that itself would call to the same action (like wp_insert_post or wp_update_post). That would result in an infinite loop. However you’re not using any of those so you’re fine.

    Basically.. your function looks fine and it works. But it might be better practice to not use the $wpdb object. One thing you need to change tho if you continue to use this is the prepare function for $wpdb. Since you’re inserting information from variables (in the front end none the less) you should really make sure to prepare them even tho you’re sanitizing the value before insertion. https://developer.wordpress.org/reference/classes/wpdb/prepare/

  • Are you setting the format according to the JS format, not PHP? (They’re different in some aspects and I’ve made that myself a few times).

  • Hi @fox and @rdourado

    Are the values saved in admin? Is it just in the frontend they’re not visible?

  • Hey,

    You need to have your select option values correspond to the markers index key (0,1,2,3) etc.

    As you can see in the script you linked there’s a global variable gmarkers that you need to push each marker into and then use to target the appropriate marker with your trigger.

    So in essence:

    1. Create a global variable (array).
    2. Push each new created marker into this array.
    3. Loop through each location to create your select options and give them the value of their key (0,1,2 etc) in a foreach loop foreach( $markers as $key => $marker ).
    4. When user selects a value from the dropdown, take the value and trigger the click event on the marker in the global array with the same index key.

    The example you sent is pretty much exactly what you need.. you just need to add these things to the ACF example code instead.

  • Hi @donnafefe

    The gallery shortcode should be able to show images even if they’re not connected to the post if you pass along image ids.

    However are you aware that you need to set the second parameter of get_field to the other posts ID if you want to fetch them from another post?

    
    <?php if ( get_field('imggal', $other_post_id) ) { ?> 
        <div class="galleria">
        <?php 
        $image_ids = get_field('imggal', $other_post_id, false);
        $shortcode = '[gallery limit="3" columns="3" order="ASC" orderby="menu_order ID" ids="' . implode(',', $image_ids) . '"]';
        echo do_shortcode( $shortcode );
        ?>      
        </div>
    <?php } ?>
    
  • Hi @brunocloutier
    Have you taken a look at your field settings? Specifically the output/input formats. What do you have there?

  • Hi @beee

    You can show the post title field to allow for creating/editing that using post_title => true in acf_form().

    To change the post status after a submission of updating an existing post you should use the acf/save_post action hook. You could update it using wp_update_post() and if you do you HAVE TO remove your acf/save_post action before and add it back afterwards. Otherwise you’ll end up with an infinite loop.

    Another way is to change it using the global $wpdb variable directly.

    
    global $wpdb;
    //Skip if this isn't a post or if status is already pending.
    if ( ! $post = get_post( $post_id ) ) return;
    if ( 'pending' == $post->post_status ) return;
    //Update DB with pending status.
    $wpdb->update( $wpdb->posts, array( 'post_status' => 'pending' ), array( 'ID' => $post_id ) );
    //clean the cache for the post
    clean_post_cache( $post->ID );
    
    //Trigger all transition hooks in wordpress (in case other functions hook into those to do things.
    $old_status = $post->post_status;
    $post->post_status = 'pending';
    wp_transition_post_status( 'publish', $old_status, $post );
    
  • Hi @robtje

    Your selected format for the time field does not affect how it’s saved to the DB. From the documentation:

    The value selected can be returned and displayed in different formats but will always be saved to the database as ‘hh-ii-ss’. This format matches the time part of any datetime value.

    So you’ll need to change your query to that format as well 🙂
    The time values are always stored as strings but if they’re strings that MYSQL recognizes as time/date you can query them as an interval in TIME format: https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

    May I also suggest that you use WP_Query instead of get_posts. When querying the database in WordPress, you should generally use a WP_Query object. WP_Query objects take a number of useful arguments and do things behind-the-scenes that other database access methods such as get_posts() do not.

  • No Problem! Glad I could help and best of luck in your project!

  • Hi @satuweb

    in what context? I need more information..
    Are you trying to look at the xhr when a new row is added?
    Or are you fetching repeater values with your own AJAX function?

  • @themightymo
    Just out of curiosity, what specific things do you feel lacking? I’ve not really felt I’m missing anything.

  • Hi @precisioncreations

    Thank’s for your example too. It’s pretty much the same as mine except you also run a transient check so as to avoid running it more than once a minute (I’m guessing?).

    A few key differences tho I think worth mentioning is:
    1. Always use WP_Query if you can. get_posts() is a wrapper for WP_Query which excludes filters. It’s just good practice tho, don’t think it has any real impact on load times.
    2. By using wp_transition_post_statusinstead of wp_update_post we only update the status column in wp_posts table. The benefit of this is that it only handles the status so it’s faster and also it wont trigger any save_post hooked functions.

  • hm okay.

    Well to create multiple forms you should be able to just add multiple instances of acf_form() to your template.
    Also make sure you add acf_form_head() above get_head().

    You should be able to find all you need here:
    https://www.advancedcustomfields.com/resources/acf_form/

    Note that you might want to change up the form ID for each form to avoid collisions.

  • Hi @leuchterits

    Sure there’s ways to do that. First read this:
    https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/

    However I suspect you want it to be a bit more dynamic 🙂
    You can loop through your real estate posts from the relationship field. And then use their post ID as the second parameter (as shown in the link above).

  • Hi @avabiz

    The acf_form() function is, as you probably figured out, not specific to your theme but an ACF function to create forms in the frontend.

    From the sound of how you go about things i suspect you’re not comfortable with coding a childtheme. Usually acf_form requires to be inserted manually in your themes templates.

    However I just recently created a small addon which allows you to create forms using shortcodes in the editor.
    https://github.com/jonathan-dejong/acf-form-shortcode

    Using that you can create forms for whatever group you want and put them wherever in your editor.

  • Hmm okay.
    I actually tried this myself the other day (as part of a project of my own).
    Did not have this issue as the image sizes changed accordingly instantly.

    What kind of hosting do you have? WP Engine for example has their own default caching.

  • Great to hear!

    Best of luck with your project and don’t hesitate to post a new topic if you need to.

  • I’d also suggest to use this plugin which’ll make it easy to split up ACF JSON in separate locations (usually plugins). We’re currently using it in a massive project where we have 10-15 of our own plugins and most of them have their own ACF JSON files.

    https://github.com/khromov/acf-local-json-manager

  • Hi @jmarceli

    The repo is private but here’s a screenshot of the changes made according to the commit history 🙂
    https://www.dropbox.com/s/ltw6tdrctioaasp/Sk%C3%A4rmklipp%202016-09-13%2012.25.17.png?dl=0

  • I’ve addressed this to Elliot on Github as a feature request.
    In my opinion it’d probably be better to change the sanitation to allow certain HTML markup to pass through.

Viewing 25 posts - 1 through 25 (of 1,024 total)

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.