From 24418a487a4c0d728c678b1382351672197b09a0 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 16 Oct 2016 10:41:51 +0100 Subject: [PATCH] allow post models to be passed into 'acf' too --- src/Models/Meta.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Models/Meta.php b/src/Models/Meta.php index d266c30..0927c17 100644 --- a/src/Models/Meta.php +++ b/src/Models/Meta.php @@ -71,8 +71,8 @@ class Meta extends Model * Grab an ACF field from the database. * * @see Meta::get() - * @param int|string|null $page page to get meta for (or name of the meta item to get - * if you want to get the current page's meta) + * @param int|string|null|Post $page page to get meta for (or name of the meta item to get + * if you want to get the current page's meta) * @param string|null $name * @param bool $format whether to format this field or not * @throws UnsatisfiedDependencyException @@ -80,6 +80,10 @@ class Meta extends Model */ public static function acf($page = null, $name = null, $format = true) { + if (is_object($page) && (is_subclass_of($page, Post::class) || $page instanceof Post)) { + $page = $page->ID; + } + if (!ctype_digit((string) $page) && $name === null) { $name = $page; $page = null; -- libgit2 1.7.2