Support

Account

Forum Replies Created

  • That’s too bad.

    Do you have any recommendations?

  • I did just notice that it does actually work if it is a field that is not within a Flexible Content field type. So if you just have a text field named “seo_description” on the page and you want to use that as the description within Yoast SEO, then you can do the below within the Yoast SEO “search appearance” settings in the description area:

    %%cf_seo_description%%

    So I guess the temporary solution is to do something like this, however this means I need to create another field for someone to enter in the specific seo description text. So if there was some way to make this just automatically pull from the current text area field I have within the Flexible Content layout I have, that would be great!

    I am guessing the %%cf_field_name%% approach doesn’t work for sub fields like the ones within repeaters, groups, flexible content, etc.

  • I actually did a fresh install and imported the fields and the issue was not there.

    So I went ahead and created a fresh install and ended up importing the page, media, and fields from the other site and the issue looks to be resolved!

    So I am not sure what exactly was the issue with the other DB, but the newer database looks to be performing without issue.

    Thanks!

  • No problem.

    Below is the code I am using to grab a random selection from a repeater field (‘after_options’).

    <?php 
    	$options = get_field( 'after_options', 'option' );
    	if( is_array( $options ) ) {
    		$option = array_rand( $options ); 
    		$signupHTML = $options[$option]['html'];
    	} 
    ?>
    <div class="signupAfter">
    	<div class="signupText">
    		<?php echo $signupHTML; ?>
    	</div>
    	<div class="signupForm">
    		<input type="text" name="fname" class="fname" placeholder="First">
    		<input type="text" name="lname" class="lname" placeholder="Last">
    		<input type="text" name="email" class="email" placeholder="Email">		 
                    <span class="button">Subscribe</span>
    	</div>
    </div>
  • This reply has been marked as private.
  • This reply has been marked as private.
  • Gotcha.

    The only problem is that I need to display the most recent uploaded images, however I also need to know which regular post those images are associated with (the uploaded images are essentially sub image fields within a repeater field on that regular post).

    I’ll look into a way to automatically publish a new custom post type post once a regular post type is created. And then, once that new custom post type post is created, the ID of that post can get updated within the regular post and the ID of the regular post get get updated within the newly created custom post type post.

  • Wow, that is great. I didn’t realize the answer would be so involved!

    Now I will throw this at you ;)…

    I was thinking through this some more and was wondering if the easiest way would be to just create a custom post type of “Image Uploads” and then do the following:

    – Each “Image Uploads” custom post type post would have the repeater field with the text area and image upload sub field and also a custom field that would be called “Associated Post”.

    – When a regular post was created on the site, a new “Image Uploads” post would be automatically created as well. And the regular post would store the ID of the newly created “Image Uploads” post (in a custom field called “Associated Image Uploads”) and vice versa (the newly created “Image Uploads” post would store the value for the regular post in the “Associated Post” field). That way they would both know they are associated with one another.

    – Then, when the regular post is displayed on the site I would be able to query that single custom post type “Image Uploads” post to display the images (using the ID stored in the “Associated Image Uploads” field).

    – And then on the homepage, I would be able to just query all “Image Uploads” post types by most recent.

    What are your thoughts on this method? Seems a lot less involved!

    The only thing I am trying to figure out is how to associate the two posts together. So here are my questions:

    1) How can I create a custom field on the regular post that would know the ID of the to-be-created “Image Uploads” post?

    2) And similarly, how would I be able to have a custom field on the “Image Uploads” post that would know the ID of the post that created it?

    It seems like I would need to create some kind of custom function that would run after a regular post is published that would automatically create the “Image Uploads” post and then update the regular post with that new “Image Uploads” post ID and also update the newly created “Image Uploads” post with the ID of the regular post that was just published. Correct?

    Hopefully this all makes sense!

    Thanks again for your help.

  • Hi John,

    Thanks so much for your willingness to help out!

    Basically I will be posting blog posts and then allowing users to be able to upload an image and description to each post (image field and text area field).

    I was thinking this would be a repeater field with those two sub fields so that they could easily be displayed as more and more users add to the post.

    And then on the homepage, I wanted to have some way to display the most recent user submissions (to any post).

    Does that make sense? Do you know an easier way I could accomplish this?

    Thanks!

  • Okay, thanks.

    This makes sense.

    However, where I am getting stuck is being able to loop through the repeater field attached to the posts to determine the most recent additions. Here is what I need to do:

    1) Query the last 10 (let’s just use 10 for now) posts
    2) Loop through the repeater field in each of those posts to grab the rows for each post
    3) Sort all the rows according to date
    4) Display the rows on the homepage in a “most recent” order

    So would it be best to grab the rows for the repeater field for each of the posts and throw them in an array. And then sort the array according to the hidden timestamp field? Something like below?

    http://stackoverflow.com/questions/6401714/php-order-array-by-date

  • I found the problem.

    I was using the latest version of ACF Pro, but was still on WordPress 4.5.4. Once I upgraded to 4.6.1, the issue was resolved.

  • And I am assuming the time() function uses the server’s time zone, correct? So the Date Time Picker date/time selected should use that same time zone as the server, correct?

  • Oh yeah, of course. Missed that.

    Thanks!

  • Awesome.

    And since I am actually using this in conjunction with a javascript function, would the below work?

    <script>
    var nowTime = <?php time(); ?>;
    var startTime = <?php strtotime(get_field('start_date_time', false, false)); ?>;
    var endTime = <?php strtotime(get_field('end_date_time', false, false)); ?>;
    if (startTime <= nowTime && nowTime <= endTime) {
    //do something
    }
    </script>

    Also, I am assuming the PHP time(); function and the Date Time Picker both use the server’s time zone, correct?

  • A little more info…

    The page where I have these two tinymce editor fields has several ACF fields on it of various types (the theme settings page for my theme).

    And I noticed that if I load the page it won’t work initially. But if I click the “Text” tab and then the “Visual” tab (which does nothing for either) and then refresh the page, that it then ends up working. However, if I refresh the page again, it is the same issue with it not working again (and I need to follow those same steps again and refresh the page).

    Very strange.

  • I spoke too soon.

    It must be an intermittent issue, because it is still happening sometimes.

  • Okay, so I found the issue.

    I had some custom code to make it so all repeater fields were automatically displayed in the collapsed state by default. This worked great, but one of the pages I forgot to set what field should be displayed in the Collapsed state “on the settings for the field” so that must have thrown some kind of Javascript error that then made it so the tunymce threw an error.

  • Not sure if it matters, but I have multiple tinymce fields on a page. Maybe that will help with the problem solving.

  • I have the same issue that just appeared.

    I am receiving the same “TypeError: r is null / wp-tinymce.php:12:18099” error.

    Is there any solution to this?

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