Support

Account

Forum Replies Created

  • Note that you have to change the fieldname and the custom image size name to your own!

  • Say you have selected the field to return image object (which is default).
    Then you actually already have all image sizes when you fetch the field..

    
    <?php 
    $image = get_field('image_field');
    echo $image['url']; //This is the full image
    echo $image['sizes']['medium']; //This is the medium image
    echo $image['sizes']['thumbnail']; //This is the thumbnail image
    echo $image['sizes']['customsize']; //This is a custom sized image
    ?>
    

    So to display an image you’ll do:

    
    <?php $image = get_field('image_field'); ?>
    <?php if($image): //dont output an empty image tag ?>
    <img src="<?php echo $image['sizes']['customsize']; ?>" width="<?php echo $image['sizes']['customsize-width']; ?>" height="<?php echo $image['sizes']['customsize-height']; ?>" alt="<?php echo $image['caption']; ?>" />
    <?php endif; ?>
    

    This will give you an image of a custom size with all the necessery values set for a legit xhtml/html5 markup.
    There’s really no reason for you to change the field to return ID and do the query yourself since it’ll just mean two queries instead of one. The only reason would be if you want to manipulate the image or perhaps fetch some more advanced info in a controlled way.

  • This isn’t really a question of ACF but rather your theme?

    If you want a select dropdown in the frontend which will change the content of the company history you’ll need to code in a select dropdown yourself and probably hook it to an ajax function which alters the content!

    If you want to be able to select between different layouts in admin when you create the post you can use the conditional logic to display different input fields in the admin depending on which choice you (or who ever is administrating the site) choose from a select created with ACF. Then it’s just a matter of doing a if statement with php in the theme where you change layout depending on which select value they chose in admin.

    Either way this isn’t so much an ACF issue as it’s a regular theme dev issue.

  • you probably cant do the_field inside a plugin unless you’re absolutely sure it loads after ACF.. I’m not too sure about it..

    Perhaps you should look at some existing plugins to help you out instead 🙂

    Seriously powerful which I use on most networks which have multiple sites with the same basic setup
    https://premium.wpmudev.org/project/new-blog-template/

    Let users switch theme after registration
    https://premium.wpmudev.org/project/advanced-theme-switcher/

  • Ahh I used to be one too, then I became both after a while 😉 It’s inevitable in a small business

    Anyway, this should do it provided that both fields are arrays!

    
    <?php 
    $checkboxValues = get_field('field_name'); //Change field_name to your checkbox field
    $morecheckboxValues = get_field('field_name_2'); //Change field_name to your checkbox field
    $extraClasses = array_merge($checkboxValues, $morecheckboxValues);
    ?>
    <?php post_class( $extraClasses ); //This goes in your <article> element (or whatever you use) ?>
    
  • Just hover over the field group in the list view and you have a red trash link 🙂

  • This will only remove the posts values, not the field itself.
    delete all _downloads as well 🙂

    Then to actually delete the field from the admin edit page you trash the field in ACF admin page.

  • Well yes,

    You’ll just setup a different flexible field area for each template part and have it contain any fields you like. Then in adding the content to the page you or the client selects which type of content you want to add and it’ll all appear in the order in which it is added.

    Should you then want to change the order you can drag and drop the flexible fields to desired position.

    I’m not an ACF developer or affiliated with ACF more than that I’ve been using it since an early stage and occasionally helping people here is a way of giving back to Elliot for what I consider the best WordPress plugin I’ve encountered 🙂

  • It’s possible but not as is..

    you’ll need to use array_merge on the fields first then put the new variable in the post_class function

  • Well, if you use the standard admin theme (not any custom in admin area) it shouldnt matter there since it’s based on wordpress own classes..

    As far as front end editing goes you’re not restricted to only using ACFs own front end form.. You could create your own form or possibly use for example Gravityform for it and use filters (for gravity forms) or a custom submit page to save the values to the users profile. You could even create your very own form with completely custom markup and styling and write some AJAX to save it to user profile without reload or requirement of a submitpage

  • Yeah that’s true 🙂 It would be more of a failsafe than a way to make sure their input is stored..

    I believe it might be possible to achieve with the new heartbeat API but I don’t think it’s been done.. Possibly it currently only supports the posts tables as well. Perhaps we’ll see it in the future!

  • Just delete the fields where meta_key is the same as you field_name was/is..
    That should be enough!

  • That’s strange since it should work.. is it possible you dont have the right field name?

    If you come so far as to find the field value in the wp_postmeta table for the post in question you can easily delete it!

    Just click the delete button next to the row which contains the data you dont want and it should be fine. If you’re nervous you can always to a export backup first 🙂

  • Do you want to list them separately on the same page or as one big array?
    This example should work to put them all in the same array which you can then use as a regular gallery array in a foreach loop to display each image!

    
    
    	
    	$args = array (
    		'post_type'      => 'page',
    		'posts_per_page' => -1,
    		'post_parent'    => $post->ID
    	);
    	$children = new WP_Query($args);
    	$gallery_array = array();
    	if($children->have_posts()){
    		while($children->have_posts()){ 
    			$children->the_post();
    			$childGallery = get_field('galleryfield');
    			if($childGallery){
    				$gallery_array = array_merge($childGallery, $gallery_array);
    			}
    		}
    		wp_reset_postdata();
    	}
    	
    	print_r($gallery_array); //This now contains all the gallery items from the childpages, provided there are any childpages and they have galleries
    
    
  • Hi,

    Try this:

    
    global $post;
    	$current_page = $post->ID;
    	$int = (int)$current_page;
    	$string_page = (string)$current_page;
    	$current_parent_page = $mv_is_subpage->ID;
    	
    	// Post selection
    	
    	$args = array (
    		'post_type'      => $post_type,
    		'posts_per_page' => $posts_per_page,
    		'orderby'        => $orderby, 
    		'order'          => $order,
    		'no_found_rows'  => 1,
    //		'category_name' => 'test'
    		'meta_query' => array( 
    			array(
    				'key' => 'assigned_page', 
    				'value' => "$string_page",
    				'compare' => 'LIKE' 
    			)
    		),
    	);
    

    Also you have some strange parameters such as “no_found_rows” and “category_name” which does not exist in the wp_query class.. These should probably be removed if you dont know what you’re doing with them.. And make sure that your variables such as $order etc. is set!

  • I dont really get what you’re after but to get both the value and the label of the field you can use http://www.advancedcustomfields.com/resources/functions/get_field_object/

  • May I ask why you’re writing a plugin simply to display an acf field?
    Since ACF fields is pretty much site dependent why not do this directly in the themes files?

    The easiest way to display a field (a directly saved value, not an array) is with the_field(‘field_name’);

  • I have no idea where to start doing this..

    Have you checked that the new Heartbeat API in WordPress does not already perform this kind of autosave for user profiles (probably not but worth a lookyloo)?

    Suppose you might be able to do something using this filter:
    https://codex.wordpress.org/Plugin_API/Action_Reference/personal_options_update

    Like register a custom JS script which upon visiting the profile page creates a session cookie (or perhaps localstorage for html5). Then you run a timed function every 10 seconds or something which looks into all the fields and saves them by field name -> value..

    Then when a person loads the edit page of their profile you check if the cookie is set and if so run through all values and input them in the approriate field (by field name).

    This is just a quick idea on how to do it and I have no idea if it’s actually doable 🙂

  • By meta boxes I assume you’re referring to different ACF field groups or fields..

    This is basically all about the themes coding, you code the fields where you want them and thats it.. If you want the user to be able to switch position of the fields outputted content simply from the admin you could try take a look at the Flexible field addon!

  • Hi,

    You’re probably hitting your servers limits.. try asking your serverprovider to increase your max_input_vars

  • On a second look it seems you can pass an array to post_class aswell.. so you really only need one line of code:

    
    <?php post_class(get_field('field_name')); ?>
    
  • seems a little hurdled around..

    
    <?php 
    $checkboxValues = get_field('field_name'); //Change field_name to your checkbox field
    $extraClasses = (is_array($checkboxValues) ? implode(' ', $checkboxValues) : $checkboxValues); //If its an array, implode it! otherwise just use the value
    ?>
    <?php post_class( $extraClasses ); //This goes in your <article> element (or whatever you use) ?>
    
    
  • You could make use of the load_field filter:
    http://www.advancedcustomfields.com/resources/filters/acfload_field/

    This should get you going!

    
    function dynamic_author_dropdown( $field ){
    	
    	$authors = get_users(array(
    		'role' => 'author'
    	));
    	
    	if(!empty($authors)){
    		foreach($authors as $author){
    			$field['choices'][$author->ID] = $author->display_name;
    		}
    	}
     
        return $field;
    }
     
    // acf/load_field/key={$field_key} - filter for a specific field based on it's key name , CHANGE THIS TO YOUR FIELDS KEY!
    add_filter('acf/load_field/key=field_508a263b40457', 'dynamic_author_dropdown');
    
  • It’ll probably be difficult since the tab layout with table is embedded in the ACF as a whole.

    the tab.php file in core/fields only outputs the tab itself and not its content.

    Perhaps a nice feature request for the future? Altho I’m pretty sure it’d end up pretty low on the priorities-list since it’s just a cosmetic alternative 🙂

Viewing 25 posts - 826 through 850 (of 1,019 total)