Support » Plugin: WebSub/PubSubHubbub » Custom Post Types and custom feeds

  • Resolved estepix


    Hi there,

    After many attempts and headaches I realised that your plugin does not notify custom post types to the hubs configured, only regular posts and comments are notified!!!

    I came up with the following solution for my custom post type and it’s working great so thought I should share it:

    /* check if the notifying function is available */
    if( function_exists( 'pshb_publish_to_hub' ) ) {
        // function that is called whenever a new post is published
        function pshb_publish_myCustomPostType($post_id) {
          // we want to notify the hub for every feed
          $feed_urls = array();
          $feed_urls[] = get_bloginfo('atom_url');
          $feed_urls[] = get_bloginfo('rss_url');
          $feed_urls[] = get_bloginfo('rdf_url');
          $feed_urls[] = get_bloginfo('rss2_url');
          $feed_urls[] = '';
          // customize default feeds
          $feed_urls   = apply_filters('pshb_feed_urls', $feed_urls);
          return $post_id;
        add_action('publish_myCustomPostType', 'pshb_publish_myCustomPostType');

    Edit: you can add this snippet to your theme’s functions.php

    You only need to replace “myCustomPostType” with your own Custom Post Type slug.
    Also, since currently only the root feed URLs are notified, you can add as many custom feeds as you want with:
    $feed_urls[] = '';

    Hope it helps!

Viewing 1 replies (of 1 total)
  • I missed it the first time round, but I realise now that for custom feeds you are better off using the filter hook enabled by the plugin guys:

    $feed_urls   = apply_filters('pshb_feed_urls', $feed_urls);

    Thanks for that guys!!!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Post Types and custom feeds’ is closed to new replies.