In the members-only forum, a user asked:
I need to know if is possible a conditional from date, for example
is_date (1 april 2017 to 1 septiembre 2017){
}
This tutorial provides the code to display a Promo Bar above header on single posts published between the specified start and end dates in Genesis.
Approach 1:
In a function hooked to genesis_before_header
, write a custom WP_Query by specifying the start and end dates using date_query, loop through the results set, store all the post IDs in an array, then check if the ID of the current post is in the $ids array and if so display the widget area.
(Thanks for the idea, Gary)
Approach 2:
Using the wp_get_timezone_string() function from skyverge's site, convert the start date, end date and the post date into Unix timestamps adjusted for WordPress timezone setting (if set) and write an if conditional comparing the post date with start date and end date to display the widget area.
Approach 1 is easier and straightforward.
Step 1
Add the following in child theme's functions.php:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.