Support

Account

Forum Replies Created

  • Sounds like you just need a developer, yes you can do it, but would need a lot more information, code, etc to be and to do so.

  • I think the problem is I don’t believe HubSpot supports multiple forms on the same page. You should contact HubSpot to confirm. I would not have a mass amount of forms on the same page anyway, ask the client why they want them on the same page, you can’t share events easily, you cant link to specific events, it makes it worse for SEO, it’s not a good idea and with HubSpot forms, doesn’t even work.

  • I’d imagine instead of saying duration of 3 days, just take the dates and check for posts that have availability on all days in question. So check if a room is available on ALL April 1st, 2nd, and 3rd. If all dates are available then show it.

    Without knowing to much about the project I’d imagine this to check a calendar and just loop through the dates between the start and end dates and check for each day is available on the calendar.

    $desired_dates = array();
    for ($date = $start_date; $date <= $end_date; $date->modify('+1 day')) {
        $desired_dates[] = $date->format('Y-m-d');
    }

    Hope this helps 👍 code is untested

  • If you have the posts linked already I think you’d just need to update the field in the relationship posts when the post is saved.

    I used update_field() and ACF/save_post

    I’ve done something similar in a solution I built to update the field values of a specific post from any page on the website.

    
    function update_variant_fields($post_id) {
    
      // Get related Base Cards using the relationship field
      $base_cards = get_field('base_card_relationship_field', $post_id);
    
      if ($base_cards) {
        foreach ($base_cards as $base_card_post) {
          $power = get_field('power', $post_id);
          $cost = get_field('cost', $post_id);
    
          update_field('power', $power, $base_card_post->ID);
          update_field('cost', $cost, $base_card_post->ID);
        }
      }
    }
    add_action('acf/save_post', 'update_variant_fields'); // Update on post save
    

    I realized after I made it could have probably changed $base_card_post->ID into its own variable.

    Hope this helps!

  • We use ACF in all our projects and could assist.

    Website Genii

  • I don’t think it’s worth the effort but in theory it may be possible..

    1. Extend ACF Block with a JavaScript Interface
    You would need to enhance your ACF block with JavaScript (likely using React if you are using the latest WordPress editor, Gutenberg) to include a user interface element, such as a button, for adding new ‘cassette_card’ posts.

    2. Use WordPress REST API
    Leverage the WordPress REST API to create new posts. You’d need to ensure that your custom post type ‘cassette_card’ is exposed to the REST API with the appropriate arguments set in the register_post_type() function, like so:

    
    register_post_type('cassette_card', [
        'public' => true,
        'show_in_rest' => true,
        // Other necessary arguments...
    ]);
    

    3. JavaScript to Handle Post Creation
    Within your block’s JavaScript, add a function that handles the creation of new ‘cassette_card’ posts. This function would use the WordPress REST API to create a new post asynchronously. Here’s a basic example using fetch API:

    
    function createCassetteCard(title, content) {
        const postData = {
            title: title,
            content: content,
            status: 'publish',  // Or 'draft' depending on your needs
        };
    
        fetch('/wp-json/wp/v2/cassette_card', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'X-WP-Nonce': wpApiSettings.nonce  // nonce for verification
            },
            body: JSON.stringify(postData)
        })
        .then(response => response.json())
        .then(post => {
            console.log('New cassette card created:', post);
            // Handle the newly created post (e.g., adding to a select dropdown)
        })
        .catch(error => console.error('Error:', error));
    }
    

    4. Authentication and Security
    Ensure that proper authentication (like nonce checks) and capability checks are implemented to secure the post creation process. The X-WP-Nonce header in the fetch API call above is crucial for security.

    5. Update the Editor Interface
    After a post is successfully created, you’ll need to update the editor’s interface to include the new post. This might mean refreshing a dropdown or a list component that lets you pick ‘cassette_card’ posts.

    6. Enqueue Scripts and Localize
    Make sure your JavaScript is properly enqueued and localized in your plugin or theme’s functions file to ensure it has access to WordPress core functionality like wpApiSettings.nonce.

    None of this is tested and may not even work. Maybe this will help though.

  • Yes, simply deactivate it and reactivate. If it gives you an issue log into your acf account, find the domain, and deactivate it there, then reactivate it on the website.

    Should be good to go then.

  • Well right now your code shows a comparison operator of “LIKE” which will indeed perform the behavior you are describing.

    https://wordpress.stackexchange.com/questions/70864/meta-query-compare-operator-explanation

    Replace LIKE with = and you should be good.

  • I am a bit confused by the question, is this sort of what your going for?

    function redirect_to_acf_file_url() {
        // Check if it is a singular "Resources" post
        if (is_singular('resources')) {
            // Get the current post ID
            $post_id = get_the_ID();
    
            // Get the URL from the ACF file field, assuming the field name is 'file_url'
            $file_url = get_field('file_url', $post_id);
    
            // Check if the URL is not empty
            if (!empty($file_url)) {
                // Perform the redirect
                wp_redirect($file_url, 301);
                exit;
            }
        }
    }
    
    add_action('template_redirect', 'redirect_to_acf_file_url');
    
  • You should have no issue with this, .local is recognized as a dev environment and my staging environments are all recognized as staging in my ACF panel. Then my production sites are properly recognized as well.

    This is from the FAQs on the pricing page.
    https://www.advancedcustomfields.com/pro/#pricing-table

    Development and staging sites are ignored and do not count towards site activation limit. For the full list of rules we apply when detecting a development or staging site, please see our License Activations guide.

  • Agreed with what John said.

    Simply put, they are working fine on your sub-sites, there was no reason for you to sync them.

  • You cannot do it natively; as John mentioned, there is a plugin.

    Though ACF has its resource on how to do so with some coding know-how.
    https://www.advancedcustomfields.com/resources/bidirectional-relationships/

  • Very nice, John I didn’t think to use wp_head, I was so focused on header.php.

    Very nice indeed! Thank you for this!

  • It seems like you have a ways to go.

    To easily get the image behind the text using a background style with css would be the best way to go. You have to make div elements or other elements though, having simply data but not way to target it doesn’t help.

    Example:

    
    
    <?php while( have_rows(‘grouped_fields’) ): the_row(); }
    ?>
    <style>
    .modal-wrap{
       display: flex;
    flex-flow: column;
    justify-content: center;
    align-items: center;
    }
    </style>
    <div class="modal-wrap" style="background: url("<?PHP echo $image_url; ?>") 50% 50% no-repeat">
        <h2><?php the_sub_field(‘title’); ?></h2>
        <p><?php the_sub_field(‘date’); ?></p>
        <p><?php the_sub_field(‘time’); ?></p>
        <p><?php the_sub_field(‘location’); ?></p>
    </div>
    <?php endwhile; ?>
  • get_field() will only work on the pages of the custom post type. This is more to do with what loops are running on which pages.

    You can access those fields a couple ways, by using get_field( ‘field_name’, ‘ID of CPT post’ ) or you can loop through using a wp_query loop and get those fields from that Custom post type.

  • Yes indeed, if you are using the updated Block method for ACF Pro that uses the WordPress block.json then everything block.json can do you can now do too.

        "editorScript": "file:./index.js",
        "script": "file:./script.js",
        "viewScript": [ "file:./view.js", "example-shared-view-script" ],

    https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/

  • Multiple ways to do it, you can position everything with absolute so that it all overlays the same div block but this can get a bit messy.

    Most likely if you just take the image and use that as a background image and do some inline CSS to get that background image then you can position the rest of the items within the div block.

    Though without going into a huge amount of detail this isn’t really anything to do with ACF this is knowing front-end development and in this case CSS.

    https://freefrontend.com/css-cards/ Here is some helpful cards you could reference

  • $my_query = new WP_Query($args));
    if($my_query->have_posts()) {
       while($my_query->have_posts()) {
          $my_query->the_post();
          /* Add all the fields your checking for here - I'm sure there is a prettier way to do this */
          if( !empty(field_1) || !empty(field_2) || !empty(field_3) || !empty(field_4) ) {
             true;
             /* Do whatever you want now */
          } else {
             /* Do Nothing? This has an empty field */
             false;
          }
       }
    }

    You can check for it when the loop it output; this way you’re not looping through every time to check each specific field, you only loop through once and don’t show it on output.

Viewing 19 posts - 1 through 19 (of 19 total)