Skip to content

Instantly share code, notes, and snippets.

View quangpro1610's full-sized avatar
🏠
Working from home

Hoang Quang quangpro1610

🏠
Working from home
View GitHub Profile
@quangpro1610
quangpro1610 / AND_OR_NOT
Created January 14, 2019 16:01 — forked from oliverdoetsch/AND_OR_NOT
Blogger: Globally conditional data tags for all page types
#AND
<b:if cond='data:blog.pageType == "index"'>
<b:if cond='data:blog.searchQuery'>
<!--search_page AND index_page-->
</b:if>
</b:if>
#OR
@quangpro1610
quangpro1610 / wp-schedule.md
Created November 1, 2018 04:13 — forked from adamdehaven/wp-schedule.md
Schedule events in WordPress

You probably already know that WordPress can schedule events. For example, it can publish posts at preset dates and times. Using hooks and wp-cron, we can easily schedule our own events. In this example, we will get our WordPress blog to send us an email once hourly.

The solution

Paste the following code block in the functions.php file of your theme.

if (!wp_next_scheduled('my_task_hook')) {
  wp_schedule_event( time(), 'hourly', 'my_task_hook' );
}