Post field

The post field type is used to select a post. In the options for the field you can choose what post types a user can select, for example only a specific custom post type.

Return

Returns the id of the selected post.

If no post is selected it will return 0.

Extended Return Values

Arguments

enable_extended_return_values
bool
enabled_post_types
Array
(
[0] => post
[1] => page
[2] => products
)
additional_arguments
cat=2

Example


// field slug is "postExample"
$post_id = simple_fields_value('postExample');
$post_title = get_the_title($post_id);
$post_url = get_permalink($post_id)

echo "You selected the post with id $post_id";
echo "The name of the post is $post_title";
echo "and the URL to the post is $post_url";

Output of above:


You selected post with id '2'.
The name of the post is 'Sample Page'
and the URL to the post is 'http://localhost/sample-page/'

2 thoughts on “Post field

Leave a Reply