acf post object

Solutions on MaxInterview for acf post object by the best coders in the world

showing results for - "acf post object"
Louis
28 Mar 2016
1<?php
2
3// DISPLAY CONTENT FOR SINGLE POST OBJECT
4
5$post_object = get_field('post_object');
6
7if( $post_object ): 
8
9	// override $post
10	$post = $post_object;
11	setup_postdata( $post ); 
12
13	?>
14    <div>
15    	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
16    	<span>Post Object Custom Field: <?php the_field('field_name'); ?></span>
17    </div>
18    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
19<?php endif; ?>
Frieda
16 Jan 2018
1<?php
2
3// DISPLAY DATA FOR MULTIPLE POST OBJECTS
4
5/*
6*  Loop through post objects (assuming this is a multi-select field) ( setup postdata )
7*  Using this method, you can use all the normal WP functions as the $post object is temporarily initialized within the loop
8*  Read more: http://codex.wordpress.org/Template_Tags/get_posts#Reset_after_Postlists_with_offset
9*/
10
11$post_objects = get_field('post_objects');
12
13if( $post_objects ): ?>
14    <ul>
15    <?php foreach( $post_objects as $post): // variable must be called $post (IMPORTANT) ?>
16        <?php setup_postdata($post); ?>
17        <li>
18            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
19            <span>Post Object Custom Field: <?php the_field('field_name'); ?></span>
20        </li>
21    <?php endforeach; ?>
22    </ul>
23    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
24<?php endif;
25
26/*
27*  Loop through post objects (assuming this is a multi-select field) ( don't setup postdata )
28*  Using this method, the $post object is never changed so all functions need a seccond parameter of the post ID in question.
29*/
30
31$post_objects = get_field('post_objects');
32
33if( $post_objects ): ?>
34    <ul>
35    <?php foreach( $post_objects as $post_object): ?>
36        <li>
37            <a href="<?php echo get_permalink($post_object->ID); ?>"><?php echo get_the_title($post_object->ID); ?></a>
38            <span>Post Object Custom Field: <?php the_field('field_name', $post_object->ID); ?></span>
39        </li>
40    <?php endforeach; ?>
41    </ul>
42<?php endif;
43
44?>
queries leading to this page
acf the field in post objectacf field type objectacf post object at optionspost object acfacf post tilleacf post object get custom fieldacf post object post type achiveacf get post object titlepost object adcfacf query post by post object fieldacf post object display post permalinkhow to show post object wpwhat contain post objectacf post object get contentacf post object idacf post object oneget field from post object acfacf pro object publication dont workpost object acf wordpressacf post object how towordpress acf post objectcategories from post object acfacf post object for productsacf get fields from custom post objectacfacf post objecyacf get post object fieldacf post object custom post typeacf get post object title uniqueacf post object from setting pageacf post object querypost objectpost object acf fieldget post object id acfdisplay acf objectacf post object get post idpostobject field acfacf post object acfpost object type acfcustom post type content from advanced custom fieldsacf post object get the contentacf add post objectget post by acf fieldacf post objectsacf custom post object via post idmultiple post object titleacf post object get termhow to get post object in multile acfhow to get post object in acfacf post object permalinkadvanced custom fields objectpost object in acfacf get field post objectspecify field for postacf object fieldacf single post objectadvanced custom fields display post object fieldacf post object categoryacf post objectget post object acfget acf from postacf post object but with categoryacf post typeget post object data in acfcustom post type acf field in overviewpermalink from post type in acf repeateracf get post objectacf post object linkpost object post titleacf select post objectget title of post acf post objectwp acf get posts where post object post objects acfacf post abjectacf post object urlhow to get post object in wordpress acfacf title post wordpress post objectacf single post object rlstandard value post object acfacf set post objectacf post object via post idcreate post object acfacf display things of post objecthow to get single post object in acfget posts from post object acfget post object value acfacf post object