https://github.com/robhurring/better_metas
Wordpress custom field wrappers to make life easier
https://github.com/robhurring/better_metas
Last synced: 10 months ago
JSON representation
Wordpress custom field wrappers to make life easier
- Host: GitHub
- URL: https://github.com/robhurring/better_metas
- Owner: robhurring
- Created: 2009-02-22T18:59:44.000Z (over 17 years ago)
- Default Branch: master
- Last Pushed: 2009-02-22T22:04:41.000Z (over 17 years ago)
- Last Synced: 2024-04-13T19:19:37.824Z (over 2 years ago)
- Language: PHP
- Homepage:
- Size: 78.1 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
Awesome Lists containing this project
README
= About
I love using custom fields for themes/plugins, but parsing them is sometimes a bitch. This is a very simple wrapper for some
wordpress functions that will return a nice formatted array for use with themes or other plugins.
If you are big into custom fields and playing around with them, check this plugin out, it should make life a bit easier.
= Examples
You have a post which has a bunch of images, but those images need titles, you can structure that in the post with custom fields like:
*custom_field_name*:: *value*
+images+:: src=image01.jpg&title=my house&description=this is my house
+images+:: src=image02.jpg&title=mountain&description=some awesome mountains
+images+:: src=image03.jpg&title=beach&description=a sandy beach
+gallery_options+:: sort=title&&lightbox=1&delay=0.5
You would get this array back:
Array
(
[images] => Array
(
[0] => Array
(
[src] => image01.jpg
[title] => my house
[description] => this is my house
)
[1] => Array
(
[src] => image03.jpg
[title] => beach
[description] => a sandy beach
)
[2] => Array
(
[src] => image02.jpg
[title] => mountain
[description] => some awesome mountains
)
)
[gallery_options] => Array
(
[sort] => title
[lightbox] => 1
[delay] => 0.5
)
)
Pretty convenient, no? To get a single custom field use +meta(_key_)+:
meta('gallery_options') => array('sort' => 'title', 'lightbox' => 1, 'delay' => 0.5)
Now you can use this within other plugins, or themes, or wherever.