WordPress “Cron Jobs”
1 |
wp_schedule_event(time(), 'hourly', 'my_schedule_hook'); |
Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed.
So if you want to execute some code on a regular base, like checking an RSS Feed, doing a database backup or reseting database values this function will do it for you. Unfortunatley its not as easy to use as transient but here is a short article on how it is done:
http://themocracy.com/2010/02/wp-cron-automating-scheduling/
http://codex.wordpress.org/Function_Reference/wp_schedule_event
Easily Fetch an RSS Feed with WordPress
1 |
$feed = fetch_feed( $uri ); |
fetch_feed is another simple wordpress method to get feed content. It also has the added benefit that it uses the SimplePie and FeedCache functionality for retrieval and parsing and automatic caching.
http://codex.wordpress.org/Function_Reference/fetch_feed
WordPress mail function
1 2 3 4 5 6 7 8 9 10 11 |
wp_mail() wp_mail( $to, $subject, $message, $headers, $attachments ); Example: $to = 'kriesi@gmail.com'; $subject = 'Hello Kriesi!'; $message = 'This message was sent by wordpress' $mail = wp_mail($to, $subject, $message); if($mail) echo 'Mail delivered'; |
An incredible useful and exceptional easy to use function that also allows you to send headers and attachments, allows plain text sending and html messages and quite a few other options!
http://codex.wordpress.org/Function_Reference/wp_mail
WordPress Shortcode API
1 |
add_shortcode(), do_shortcode() |
add_shortcode() is an easy way to create macros for your post content. for example lets say you want to wrap some content inside the post area within a div with some additional classes and ids that allows you to create multiple columns. you could of course just switch to the html editor and enter
1 |
<div class='one_third'>Content goes here</div> |
Easier and more convenient especially if you are dealing with customers who dont know html would be a shortcode solution within your functions.php file:
1 2 3 4 5 |
function column_shortcode( $atts, $content = null ) { return "<div class='one_third'>" . $content . "</div>"; } add_shortcode('one_third_column', 'column_shortcode'); |
You could then use this shortcode in your post content:
1 |
[one_third_column]Content goes here[/one_third_column] |
If you would like to nest shortcodes within each other you would need to make sure to add the do_shortcode method to your function like this:
1 2 3 |
column_shortcode( $atts, $content = null ) { return "<div class='one_third'>" . do_shortcode($content) . "</div>"; } |
http://codex.wordpress.org/Shortcode_API
Create WordPress post with a php function:
1 |
wp_insert_post() |
This function inserts posts pages and custom post types in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. very handy when you need to create and insert posts by user input. This function fits perfectly if you have a front end form for example and users can suggest posts.
http://codex.wordpress.org/Function_Reference/wp_insert_post

Chris

Latest posts by Chris (see all)
- Global Smarty Variables used in Prestashop - Thu, 15 Aug, 2013
- How to know the current page is home or not in prestashop - Fri, 9 Aug, 2013
- How to change the logo link url on wordpress login form - Fri, 9 Aug, 2013