acf_field_post_object::render_field
Create the HTML interface for your field
Method of the class: acf_field_post_object{}
No Hooks.
Returns
null. Nothing (null).
Usage
$acf_field_post_object = new acf_field_post_object(); $acf_field_post_object->render_field( $field );
- $field(required)
- .
Changelog
| Since 3.6 | Introduced. |
acf_field_post_object::render_field() acf field post object::render field code ACF 6.0.4
function render_field( $field ) {
// Change Field into a select
$field['type'] = 'select';
$field['ui'] = 1;
$field['ajax'] = 1;
$field['choices'] = array();
// load posts
$posts = $this->get_posts( $field['value'], $field );
if ( $posts ) {
foreach ( array_keys( $posts ) as $i ) {
// vars
$post = acf_extract_var( $posts, $i );
// append to choices
$field['choices'][ $post->ID ] = $this->get_post_title( $post, $field );
}
}
// render
acf_render_field( $field );
}