Hacking the WordPress Social Plugin to Include Pages in Addition to Posts

I love the WordPress Social plugin, which grabs Twitter and Facebook responses to a WordPress post, and compiles them as comments along with the original post. But I get plenty of social media attention on the stand-alone pages on my site — that is, instructional handouts that I use year after year, so it’s posted in a hierarchical layout, not a chronological order like my blog.

Once I learned that WordPress treats pages as a type of post that is hierarchal, I noticed this bit of code that excluded hierarchical posts. So I commented out the bit that requires the property ‘hierarchical’ to be falls, and hooray — it works.

public static function broadcasting_enabled_post_types() {
  return apply_filters('social_broadcasting_enabled_post_types', get_post_types(array(
    'public' =>; true
/**,
*   'hierarchical' =>; false
*/
    )));
 }

Note to future self: you’ll probably have to redo this edit the next time the WP-Social plugin is updated. But for the time being, it works.The developer of the plugin recommends that we use filters instead, and of course he’s right, but learning what we should do is not the same as learning how to do it. I’d need to take a crash course in WP filters, and I’m sure I’d be happy once I did, but for now, the hack is working.

If you want to carry out this hack yourself, you’ll need to edit the file social/social.php, which is in your plugin directory. (If you’re not sure what I mean by that, then you might want to get a WordPressy friend to help you.)

Update: here’s a screenshot showing the new menu option, that lets you check for new social media references to WordPress pages.

20120801-154847.jpg

13 thoughts on “Hacking the WordPress Social Plugin to Include Pages in Addition to Posts

  1. Dear Professor, please forget my last question. I must have made a mistake with the code first time.
    I tried again and now i got it to work on pages again.
    Sorry if i took up your time

    • Oh, good. I was keeping your comments in mind for the next time I wanted to share a page on my site, but the opportunity hadn’t come up yet. Thanks for the update.

  2. Hi Professsor,
    hope you had a good start into the new year. Since implementing your personal hack things were running great till Social was updated to the latest version.
    The code looked a bit different, but i still tried to implement your solution. It broke my test site, fortunately i just have to restore it and then all is like before, which means for the time being i can not share my pages with social, only posts.
    Did you experience the same problem?
    regards, Viktor

  3. Great post!
    Do you know how to remove the default commenting box with the social plugin, allowing commenting only through fb and twitter?
    Thanks

    • I would try using CSS to hide the part of the code that displays the comment box. I recognize that if you don’t already know how to do CSS that may not help much, but technically speaking it’s not very difficult to hide any part of a website.

      • Thanks for the reply,
        I will try hiding it with css. I have multisite in mind and wish to use social as default commenting system but want to avoid spam bots from using this default commenting box. not sure if css with help. As you are using Social, does it helps to cut on spam/bots comments ?
        Thanks.

  4. Thnak you for the reply. I looked at the Jetpack but it does not look like it alters the menu. I will keep looking to find a plugin to get that.
    Or maybe Alex King will finally hear our desperate calls ;-)

    • Thank you for the reply and the screenshot.
      Since yesterday i have already found out, that automatic search happens also on pages, and when you are in the edit screen you have the manual search, it just does not show up in the overview-list of pages.
      Now i would be very curious how you got the “find social comments” in the menu.
      Is that part of the code you posted first (i only copied part of it into my social.php)?
      Kind regards, Viktor

  5. Dear Professor Jertz,

    i tried your solution, and it worked as far as posting is concerned. Thank you so much.

    Now all we have to do is:
    -get Alex King and mailchimp to adopt it
    -and what i do not know yet is, if social comments will also be imported for pages, because i do not see that button one finds with articles to check for social comments.

    But anyway, thanks again.

    I am still considerng switching back to Wordbooker, but this might stop me.

    Kind regards, Viktor

Leave a Reply

Your email address will not be published. Required fields are marked *