Skip to content

Instantly share code, notes, and snippets.

@gboone
Created September 2, 2017 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gboone/ca92b124daa91a73c7f02db4e090e479 to your computer and use it in GitHub Desktop.
Save gboone/ca92b124daa91a73c7f02db4e090e479 to your computer and use it in GitHub Desktop.
A jekyll filter to sort out and return only the wp:post_meta keys and values
module Jekyll
module WPmetadata
def wpmeta(input)
standard_post = [
"output",
"content",
"relative_path",
"path",
"url",
"collection",
"next",
"previous",
"id",
"draft",
"categories",
"layout",
"title",
"tags",
"slug",
"ext",
"date",
"excerpt",
"author",
"permalink"
]
postdata = input.delete_if {|x| standard_post.index(x)}
end
end
end
Liquid::Template.register_filter(Jekyll::WPmetadata)
# use in a template like this {{ post | wpmeta }}
# returns a hash like { "key" => "value" } for any
# keys in the post hash that are not in the array
# of standard post values (lns 4-24).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment