Support

Account

Forum Replies Created

  • That worked great thanks 🙂

  • Hi John,
    Thanks for the response but thats a bit over my head, im unsure how i can update the field with that.

  • Hi John,
    I am trying to update the prepend field in a cpt edit screen with a value from the options section ‘get_field(‘property_prefix’,’options’)’. so when an admin goes to the edit screen the prepend field is populated with the prefix entered in the options screen.

    I can do it by jQuery but it stops the admin pages from working:
    echo 'jQuery(".acf-field-number .acf-input-prepend").text("'.get_field('property_prefix','options').'")';

    Any help would be appreciated thanks

  • Hi John,
    That was very helpful thanks but I would like to take it a bit further, I have made a field called ‘property_prefix’ in the options panel as a text field and then I want to update the prefix of a custom field called ‘reference’ when editing in my CPT ‘properties’ so I have done this but I can’t seem to get it to update.

    if ( is_admin() || $post_type === 'properties' ) {
    	$post_id = isset( $_GET[ 'post' ] ) ? $_GET[ 'post' ] : - 1;
    	$field = get_field_object('reference', $post_id);
    	$fieldToUpdate = $field['prepend'];
    	$valueToUpdate = get_field('property_prefix','options');
    	
    	// echo "field: " . $fieldToUpdate . "<br />value: " . $valueToUpdate . "<br />post ID: " . $post_id; this shows the correct information
    	
    	update_field( $fieldToUpdate, $valueToUpdate, $post_id );
    	}

    I can do it by jQuery but would rather not to as when the page loads there is a delay before the prefix is shown.

    Any help would be appreciated, thanks

  • Hi James,
    Sorry for the long time to reply, I have now posted a ticket.

    thanks
    Graham

  • Hi James,
    Yes I have, its exactly the same no change.

    thanks
    Graham

  • Perhaps I could use a session and set the timeout for the session, then check to see if the session is set, if not to generate the file, I will look closer tomorrow and update here accordingly.

  • Thank you John for your reply, however I found another solution although its still early days of testing yet:

    I managed to create a file called main.css.php where I put only my css code and the ACF php code and then added this to my functions file:

    
    function generate_options_css() {
        ob_start(); // Capture all output into buffer
        require_once dirname( __FILE__ ) . '/main.css.php';
    	$css = ob_get_clean(); // Store output in a variable, then flush the buffer
        file_put_contents(dirname( __FILE__ ) . '/main.new.css', $css, LOCK_EX); // Save it as a css file
    	
    	wp_enqueue_style( 'main_css', get_template_directory_uri() . '/main.new.css' );
    }
    add_action( 'wp_enqueue_scripts', 'generate_options_css' );
  • Thanks @joachim, that worked great. Does anyone know when a permanent fix will be made for this?

  • Hi I am also encountering this issue but the fix noted above resolves the issue in the admin but not on the front-end, as you can see here: https://www.dropbox.com/s/o0r0qrrd6lj8i9c/googlemapissue.jpg?dl=0

    Is there any solution?

  • After some research today I found out this was the culprit:

    <meta property=”og:image” content=”<?php echo $galleryCarouselImage[‘url’]; ?>” />

    It seems to confuse the flexslider carousel

  • Hi James,
    The static code I provided is the code that actually works as I hand coded it and is not the generated code, but the static code works as I expect however when I initiate the foreach loop it as mentioned it jumps to the wrong slide.

    Thank you for providing your code however that broke the gallery, flexslider can be initiated multiple times as shown here: http://flexslider.woothemes.com/thumbnail-slider.html and by using:

    $('#gallerycarousel').flexslider({
                animation: "slide",
                controlNav: false,
                animationLoop: false,
                slideshow: false,
                directionNav: true,
                itemWidth: 300,
                itemMargin: 10,
                animationLoop: true,
                asNavFor: '#galleryslider'
            });
    
            $('#galleryslider').flexslider({
                animation: "slide",
                controlNav: false,
                animationLoop: false,
                slideshow: false,
                directionNav: true,
                sync: "#gallerycarousel"
            });
  • Hi James,
    Sorry to jump on someone elses topic but I am also having the same issue, after some testing I found out the slider carousel works fine with static HTML however when I introduce the ACF foreach loop it doesn’t like it, I checked firebug but I have no javascript errors.

    Regards
    Graham

  • Thanks John, that solved it.

  • Hi John,
    Thanks for the fast reply, I checked that and triple checked it, as seen in the screenshot you will see it is so it doesn’t make sense that a ID is only outputted.

    thanks
    Graham

  • Hi John,
    Thanks for replying its a difficult one, I recently changed it to custom post types and then like you said changed the repeater to be a post object, but even now im still struggling on how to do the appropiate SQL query because the current logged in user is assigned the company (which is a post type now) and a agent (another post type) but i need to display the companies details: logo, email address, telephone number and also the agents details (skype, email address, phone number, linkedin and a personal message) which should be personal to that user.

    I have looked at the database and it appears to be a difficult SQL query, I have no idea where to start.

  • I have managed to create a text field in ACF called assigned_company which I have gave a css class too of assignedCompany and then in jquery told it to populate the text field with the value of whatever was chosen in the dynamically generated dropdown menu:

    $( ".assign_company select option" ).click(function() {
    		var text = $( this ).text();
    		$( ".assignedCompany input" ).val( text );
    	});

    and then have pulled that from the front-end however I can’t seem to get the other values: company_email, company_number, and company_logo. I would like to get the appropiate unique value depending on what company the user selected.

  • Thanks John and Elliot,
    That fixed it, I can’t believe I forgot about that after reading through all the documentation.

    Elliot: Do you think in the future people will be able to change the image when a image field is set?

    Graham

  • Hi John,
    OK I have just tried both of those and nothing appears, I even deleted the repeater and sub rows and then readded them under a different name, here is my code:

    <?php if( have_rows('social') ): ?>
    
    					<?php while( have_rows('social') ): the_row(); ?>
                            <a href="<?php the_sub_field( "media_image" ); ?>" target="_blank"><img src="<?php the_sub_field( "media_link" ); ?>" /></a>
                        <?php endwhile; ?>
                    
                     <?php endif; ?>

    I don’t see anything wrong there?

  • Hi John,
    No caching plugin, I don’t like those when I am developing websites.

    Here is the code:

    <?php if(get_field('social_media_section')): ?>
    
    					<?php while(the_repeater_field('social_media_section')): ?>
                            <a href="<?php the_sub_field( "social_media_image_link" ); ?>" target="_blank"><img src="<?php the_sub_field( "social_media_image" ); ?>" /></a>
                        <?php endwhile; ?>
                    
                     <?php endif; ?>

    It did work yesterday but then I went and deleted a image and since then it stopped working. If you need admin access I can provide that, or FTP info as its on a site in development.

  • Hi John,
    OK thanks, I don’t know if this is related to the above, but I deleted the image as you mentioned and added another, but the new image isn’t being reflected on the front-end, I have gone as far as renaming the group name (not group label) and as it was a repeater, the sub names (not sub labels) and I am still having the same issue.

    Perhaps I am doing something wrong or is this a bug?

    Graham

  • Hi John,
    Yeah I mean change the image for a completely different image, will this be a feature in future releases as I see that being more important than manipulating a image.

    Regards
    Graham

  • Hi John,
    Thanks for the fast response, I saw that and upon clicking on the edit icon (pencil) there is no option to change the image in the popup that appears, is there anyway I can allow the option for the images to be updateable via the admin cp?

    thanks
    Graham

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