GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   wordpress tip: control when your posts are displayed in your rss feed (https://gfy.com/showthread.php?t=880032)

fris 01-07-2009 05:53 AM

wordpress tip: control when your posts are displayed in your rss feed
 
The problem. Have you ever published an article and then immediately noticed an error? Sure, you can edit it, but there?s another problem: the article has already been published in your RSS feed. To avoid this kind of problem, use this recipe to create a delay between the publication of a post and its availability in your RSS feed.

The solution. To apply this hack, simply paste the following code into your theme?s function.php file. If your theme doesn?t have this file, just create it.

Code:

function publish_later_on_feed($where) {
        global $wpdb;

        if ( is_feed() ) {
                // timestamp in WP-format
                $now = gmdate('Y-m-d H:i:s');

                // value for wait; + device
                $wait = '5'; // integer

                // http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_timestampdiff
                $device = 'MINUTE'; //MINUTE, HOUR, DAY, WEEK, MONTH, YEAR

                // add SQL-sytax to default $where
                $where .= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
        }
        return $where;
}

add_filter('posts_where', 'publish_later_on_feed');

Code explanation.

The above code will add a 5-minute delay to the time between when your post is published on your blog and when it appears in your RSS feed. To change the length of the delay, change the value of the $wait variable on line 9.

StaceyJo 01-07-2009 06:00 AM

Thanks. I bookmark this for future use.

munki 01-07-2009 06:01 AM

The wordpress ninja strikes again...

tranza 01-07-2009 06:37 AM

Nice tip man....thanks!

Ethersync 01-07-2009 07:53 AM

Gracias..

StaceyJo 01-07-2009 08:33 AM

wow...thanks for this tip...

2012 01-07-2009 09:35 PM

thanks for sharing :D

teg0 01-07-2009 10:42 PM

nice idea, but Im thinking its not the best implementation since it requires activity on your blog sometime after 5 minutes as past for the update query to run

KillerK 01-08-2009 01:38 AM

Are you being helpful cause your brother rips people off?

fris 01-08-2009 05:41 AM

Quote:

Originally Posted by KillerK (Post 15297228)
Are you being helpful cause your brother rips people off?

Do you ever say anything useful?

And the answer is no.

Go back to being a troll

Tjeezers 01-08-2009 07:56 AM

Thanks for sharing


All times are GMT -7. The time now is 09:09 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123