Created
September 2, 2017 17:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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