Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save DigitalEssence/c8881ed0bd31e1ceda4cd0c2ed0f6a6c to your computer and use it in GitHub Desktop.

Select an option

Save DigitalEssence/c8881ed0bd31e1ceda4cd0c2ed0f6a6c to your computer and use it in GitHub Desktop.
WordPress - Enfold - PHP - Check if a post date is in the past
// For Enfold copy /enfold/config-templatebuilder/avia-shortcodes/postslider.php
// to /child-theme/shortcodes/postslider/postslider.php
// Add this query
if (strtotime(get_the_date( "Y-m-d", $the_id )) < strtotime(date("Y-m-d"))) {
//Do something
}
else {
//Do nothing
}
// In functions.php add the following to enable child theme shortcodes
// Enable shortcodes to be loaded from child theme - used for postslider.php edits
add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
function avia_include_shortcode_template($paths)
{
$template_url = get_stylesheet_directory();
array_unshift($paths, $template_url.'/shortcodes/');
return $paths;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment