Results 1 to 5 of 5

Thread: function get_lastpostmodified with feed updates on custom post types

  1. #1
    Frumph is offline Hello World
    Join Date
    Sep 2009
    Posts
    34

    Icon5 function get_lastpostmodified with feed updates on custom post types

    Trying to figure out how to add_filter to the get_ladpostmodified so that when custom-post-types are updated it will recognize the feed is updated.

    However from what I can see in that plugin the filter only allows you to modify the return data from the wpdb and not the actual sql statement?

    Any advice?

  2. #2
    Utkarsh is offline Hello World
    Join Date
    Nov 2009
    Posts
    73

    Default

    How about
    PHP Code:
    add_filter('get_lastpostmodified''my_lastpostmodified');
    function 
    my_lastpostmodified()
    {
        global 
    $wpdb;
        
    $add_seconds_server date('Z');
        return 
    $wpdb->get_var("SELECT  DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER  BY post_modified_gmt DESC LIMIT 1");

    Last edited by Utkarsh; 06-23-2010 at 11:01 AM.

  3. #3
    Frumph is offline Hello World
    Join Date
    Sep 2009
    Posts
    34

    Default

    ^ awesome, however does this add to the wp_cache_set so that the feed retains it's cache'ing or will this happen every feed load?

  4. #4
    Utkarsh is offline Hello World
    Join Date
    Nov 2009
    Posts
    73

    Default

    Quote Originally Posted by Frumph View Post
    ^ awesome, however does this add to the wp_cache_set so that the feed retains it's cache'ing or will this happen every feed load?
    PHP Code:
    add_filter('get_lastpostmodified''my_lastpostmodified');
    function 
    my_lastpostmodified()
    {
        
    $lastpostmodified wp_cache_get"lastpostmodified:custom:server"'timeinfo' );
        if ( 
    $lastpostmodified ) return $lastpostmodified;
        global 
    $wpdb;
        
    $add_seconds_server date('Z');
        
    $lastpostmodified $wpdb->get_var("SELECT  DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER  BY post_modified_gmt DESC LIMIT 1");
        
    wp_cache_set"lastpostmodified:custom:server"$lastpostmodified'timeinfo' );
        return 
    $lastpostmodified;


  5. #5
    Frumph is offline Hello World
    Join Date
    Sep 2009
    Posts
    34

    Default

    That is great Utkarsh thank you, would make a great blog post on adding custom post types to feeds if you made one ;)


    Last edited by Frumph; 08-24-2010 at 11:09 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •