An open API service indexing awesome lists of open source software.

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

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.