wordpress tip: control when your posts are displayed in your rss feed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fris
    Too lazy to set a custom title
    • Aug 2002
    • 55679

    #1

    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.
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.
  • StaceyJo
    Confirmed User
    • Mar 2008
    • 8960

    #2
    Thanks. I bookmark this for future use.
    /_______ WebCashMaker ______\
    | _TeenageDecadence - Young Board Naked Teens. |
    | ____ NonNudeGirls - Female Puberty Photos. ____ |
    | _ HerSelfPics - The ORIGINAL exGF SelfPic site. __ |
    \.______ xPosing - Wife Photosharing site. _______./

    Comment

    • munki
      Do Fun Shit.
      • Dec 2004
      • 13393

      #3
      The wordpress ninja strikes again...

      I have the simplest tastes. I am always satisfied with the best.” -Oscar Wilde

      Comment

      • tranza
        ICQ: 197-556-237
        • Jun 2003
        • 57559

        #4
        Nice tip man....thanks!
        I'm just a newbie.

        Comment

        • Ethersync
          Confirmed User
          • Mar 2008
          • 5289

          #5
          Gracias..
          The best ePassporte replacement I have found: OKPAY

          Comment

          • StaceyJo
            Confirmed User
            • Mar 2008
            • 8960

            #6
            wow...thanks for this tip...
            /_______ WebCashMaker ______\
            | _TeenageDecadence - Young Board Naked Teens. |
            | ____ NonNudeGirls - Female Puberty Photos. ____ |
            | _ HerSelfPics - The ORIGINAL exGF SelfPic site. __ |
            \.______ xPosing - Wife Photosharing site. _______./

            Comment

            • 2012
              So Fucking What
              • Jul 2006
              • 17189

              #7
              thanks for sharing :D
              best host: Webair | best sponsor: Kink | best coder: 688218966 | Go Fuck Yourself

              Comment

              • teg0
                Confirmed User
                • Jan 2006
                • 4204

                #8
                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

                Comment

                • KillerK
                  Confirmed User
                  • May 2008
                  • 3406

                  #9
                  Are you being helpful cause your brother rips people off?

                  Comment

                  • fris
                    Too lazy to set a custom title
                    • Aug 2002
                    • 55679

                    #10
                    Originally posted by KillerK
                    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
                    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.

                    Comment

                    • Tjeezers
                      Webmaster
                      • Mar 2007
                      • 16602

                      #11
                      Thanks for sharing

                      Get 43 FREE Backlinks when joining SWAG Live - Click my banner to get the links!

                      Comment

                      Working...