Created
September 29, 2015 10:37
-
-
Save Sitebase/8c7f44de3076efa34656 to your computer and use it in GitHub Desktop.
Add comments based on meta data under each gallery entry in modern gallery template
This file contains 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
/** | |
* Add specific meta field under each entry in the gallery | |
* | |
* styling can be done using: | |
* .reason { | |
* ... | |
* } | |
* | |
* Replace `meta.waarom` with something else to use another meta key | |
*/ | |
window.bbbx_modules = window.bbbx_modules || []; // Make modules array if not yet exists | |
window.bbbx_modules.push(function(sandbox, $) { | |
var NAME = 'wpgreasonmeta'; | |
var exports = { | |
NAME: NAME, | |
init: function() { | |
window._template = BBBX.template.parse; | |
BBBX.template.parse = this.parse; | |
}, | |
parse: function(template, data) { | |
if( | |
data.hasOwnProperty('meta') && | |
data.meta.hasOwnProperty('waarom') && | |
template.indexOf('entry') > -1 | |
) { | |
template = template.replace('</figure>', '</figure><div class="reason" style="text-align:center; padding: 10px"><%= meta.waarom %></div>'); | |
} | |
return window._template.apply(this, arguments); | |
}, | |
destroy: function() { | |
BBBX.template.parse = window._template; | |
} | |
}; | |
return exports; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment