1000+
Reviews!
1000+ Reviews!
SEARCH SITE
Favorites
Cart
SEARCH
1000+ Reviews!
Click To Call Us Now!
SEARCH
Favorites
Cart
SAVE THE DATES
WEDDING INVITATIONS
THANK YOU CARDS
EXTRAS
MAKE DEPOSIT
BLOG
MY CART
MY ACCOUNT
CONTACT US

POST META-DATA INFO

Page ID:771
You can get a page's ID with 'get_the_ID( )'
You can get a page's meta_data by using "get_post_meta(get_the_ID( ))" and printing it out with "print_r( )"
After creating a new page the only meta_data that exists is the '_edit_lock' which is a random number that I don't understand.
You can update a page's template with "update_post_meta('thePageID', '_wp_page_template', 'thedirectory/thefile.php')"
Once the metadata exists you can access it with "get_post_meta('thePageID', 'theMetaKey')" which in the case of the template was "_wp_page_template"
But it will be stored in an array. Here's an example...

   I created a custom meta field, "test-data", using update_post_meta(get_the_ID( ), 'test-data', 'This is test data')
   Trying to use "echo get_post_meta(get_the_ID(), 'test-data')" just prints out "Array"... so what can you do?
   Let's create two variables, "$postMeta" and "$customMeta", to show some options.
   I set $postMeta to "get_post_meta(get_the_ID( ))" which grabs ALL of the post meta for the page.
   I set $customMeta to "get_post_meta(get_the_ID( ), 'test-data')" which grabs ONLY the one meta key.
   Here's what you see if you use print_r on $postMeta...

Array ( [test-data] => Array ( [0] => This is test data ) [_wp_page_template] => Array ( [0] => info-dump/post-meta-data-info.php ) )

   And here's what you see if you use print_r on $customMeta...

Array ( [0] => This is test data )

   Using $postMeta['test-data'][0] I get: "This is test data"
   Using $customMeta[0] I get: "This is test data"

   Is there a better way? If so I haven't found it yet.