Support

Account

Forum Replies Created

  • If you only have one layout option you should use the repeater-field instead since that’s pretty much exactly what it is 🙂

    It’s also an easier setup and easier to output!

  • One day you’ll see sourcecode of The Matrix!

    in all seriousness I meant it more in a way that I haven’t been at it for that long, so it doesn’t have to take 15 years in the business to develop it ^_^

  • Well I’m only 23 so it might not take so long if you keep it up! 😉

  • Oh well.. It’s probably not counting $gallery because it’s not in the format that I had pictured in my head. Nothing to worry about since you have a working loop in any case 🙂

  • Great 🙂

    Aye I suppose it works with the_field as well.. it’s just the paranoid coder inside me that doesn’t like it when something echoes things out for me =P

  • Np Kevin, glad to be of help 🙂

  • Well I’m pretty sure menu_order isn’t included in the post object so there’s no way to do this after fetching the array of objects.. Your best bet is to either make a copy of the field like I said or ask elliot to include the option in the next version..

    Another solution might be to switch from the post object field to the relationship field.. that way you can control the order of the posts by the order you select them in the field (instead of menu order)

  • you have the image field set to return the image object rather than just the URL..

    go into your field group and change the field to return just the URL, then replace the_field(‘splash’); with echo get_field(‘splash’);

  • it seems you’ve created your own form for creating the posts so you’d just have to add in the input fields as you like them and in the submission you insert them in the proper custom meta field using either wordpress update_post_meta function or ACFs update_field function (check documentation).

  • I realize why my previous loop didn’t work too 🙂

    When doing the foreach loop the $image become a detached variable of the value in the array.. so adding $image[‘constrain’] does not affect the original array..

  • Great 🙂

    Altho you could change that loop to a for-loop:

    
    for($i = 0; $i > count($gallery); $i++){ //loop through the images in the gallery
    	$gallery[$i]['constrain'] = get_field('constrain', $gallery[$i]['id']);
    }
    
    
  • Aaaahh..

    It seems that the returned data is an object rather than an array..I’m not sure wether this is due to your json encoding or not tho. When checking the documentation it’s clearly an array and not an object..

    If this is what you get back using my code it does seem to run through the foreach since you do get something in “gallery” the issue seems to be that it does not add constrain which it should.

  • Hi!

    My best guess would be that this:

    
    get_field('child_pages', false, false);
    

    does not work anymore.. since you’re getting the 5 latest blogposts it would suggest that $ids is empty and you’re making a standard get_posts call..

    What you’re doing is a bit strange tho.. you’ve got a ACF field which fetches all of the posts you want and you want to extract the ids to make a new query which does the very same thing. The only difference is that you want it ordered by menu_order..

    If you’re not afraid to do a little bit of digging a better solution would be to copy the post_object field file from ACF core and make your own field which only outputs ID.. I think I’ve made such changes before but I can’t find them now..

  • This is probably related to your other post where you only see “F” in the dropdown..

    Do you have ACF installed as a regular plugin?

  • Hi!

    Have you made any changes to the option page via the filters that are in place?

  • @Kevin

    I see.. I think you should do something like this.. Assuming that I fetch the image ID correctly from the images array this should work 🙂

    
    <?php
    function buildGallery(){
    	$post_title = $_REQUEST['post_title'];
    	if($post_title){
    		$work = new WP_Query( array(
    	        'post_type' => 'work',
    	        'post_status' => 'publish',
    	        'numberposts' => '-1',
    	        'order' => 'asc',
    	        'name' => $post_title 
    	    	)
    	    );
    	    foreach ($work->posts as $work_post) {
            	$post_id = $work_post->ID;
        	}
    	}else{
    		//get the data from ajax() call
    		$post_id = $_REQUEST['post_id'];
    	}
    	$gallery_item = array(
            "gallery_item" => array()
        );
    
    	global $post;
    	$post = get_post($post_id);
    
    	$previous_post = get_previous_post();
    	$next_post = get_next_post();
    	
    	//Fetch the gallery for the selected post
    	$gallery = get_field('gallery', $post_id);
    	if($gallery){
    		foreach($gallery as $image){ //loop through the images in the gallery
    			$constrain = get_field('constrain', $image['id']); //fetch our custom field
    			$image['constrain'] = $constrain; //Add it to the image array
    		}
    	}
    	
    	array_push($gallery_item['gallery_item'], array(
            "images" => $gallery, //output the new modified gallery array
            "title" => get_the_title($post_id),
            "content" => apply_filters( 'the_content', get_post_field('post_content', $post_id)),
            "nextLink" => $next_post,
            "prevLink" => $previous_post,
            "id" => $post_id,
            "postName" => $post->post_name,
            "company" => get_field('company', $post_id),
            "tags" => wp_get_post_tags($post_id)
        ));
    	// Return the String
    	die(json_encode($gallery_item));
    }
    
    ?>
    
    
  • you could just call it like:

    
    <?php
    $constrain = get_field('constrain', $image['id']); //$image being the single image in the gallery array
    
    ?>
    
    

    Since it’s basically just another meta-data for a post.

  • Hi Devin,

    I think the main issue here is that the way the current conditional logic is working is that it checks for the specific fields and the requirements.. however in a repeater field or flexible field there’s (theoretically) infinite numbers of the same field. So in order for the conditional logic to work the code for checking this would have to be able to operate within just it’s own set of fields when a new “fieldgroup” is added in a flexible field..

    It’s a bit confusing I know but I think you get my point 🙂

    Now I’m not saying it would be impossible to do but it could be very hard (or fairly easy for that matter) to do! I couldn’t tell without digging through alot of ACF core 🙂

  • Hi!

    You’ll need to first change it to unix timestamp and then use
    date_i18n function.. here’s a snippet:

    
    <?php $timestamp = strtotime(get_field('yourdatefield')); ?>
    <time datetime="<?php echo date(DATE_W3C); ?>" pubdate class="updated"><?php echo date_i18n( 'j M', $timestamp); ?></time>
    
    

    The key parts here is the first row and then the date_i18n function.. Change the first parameter of date_i18n (j M) to whatever timeformat you require 🙂

  • I think that if all of these are implemented it’d be important that you’d have to option to enable or disable them..

    I feel like this is on the verge of becoming one of those monsters where most people wont ever use the features added and just find it annoying

  • Have you read the documentation on how the flexible field works?

    It’s a field just like repeater field that you choose from the fieldtypes and then you put other fields inside it..

    http://www.advancedcustomfields.com/resources/field-types/flexible-content/

  • Hi!

    You’re asking for too much.. but to get you started. You need to use the functions get_field and/or the_field to display the ACF fields:

    http://www.advancedcustomfields.com/resources/getting-started/code-examples/

    http://www.advancedcustomfields.com/resources/getting-started/displaying-custom-field-values-in-your-theme/

    those links should get you going.

  • Hi!

    There is already the possibility to add fields to the profile page..Check your location rules for “user” and set the user role..

    Then to output them you have to set the second parameter to user_<userID>

  • Hi,
    Alright 🙂

    Yeah Elliot mentioned that it would not be possible for him to simply copy over the entire file since changes had been made to the field in the latest update but rather he had to copy over the changes!

  • Hi @wdekreij

    This should about do it.. Place this in your functions.php

    
    <?php
     
    function acf_set_featured_image( $value, $post_id, $field  ){
        
        if($value != ''){
    	    //Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	    add_post_meta($post_id, '_thumbnail_id', $value);
        }
     
        return $value;
    }
    
    // acf/update_value/name={$field_name} - filter for a specific field based on it's name
    add_filter('acf/update_value/name=cursusfoto', 'acf_set_featured_image', 10, 3);
     
    ?>
    
    
Viewing 25 posts - 926 through 950 (of 1,019 total)