WordPress.org

Ready to get started?Download WordPress

Forums

Social
[resolved] Social for custom posts (8 posts)

  1. nijip
    Member
    Posted 2 years ago #

    Hi,

    I notice Social doesn't apply to custom post types.
    Is there a way to change this, it would be great to have this ability.

    http://wordpress.org/extend/plugins/social/

    http://wordpress.org/extend/themes/social/

  2. Alex King
    Member
    Plugin Author

    Posted 2 years ago #

    use the social_broadcasting_enabled_post_types filter.

  3. erikeric
    Member
    Posted 2 years ago #

    How exactly do we enable this? I've found that line in the social.php file but I am not sure how to change it to enable custom post types. Do I just add another array() command to that line?

  4. erikeric
    Member
    Posted 2 years ago #

    Nevermind, figured it out. If anyone else wants to know:

    Go to the plugins page. Click the "Edit" link under Social's entry. Do a find-in-page search for "social_broadcasting_enabled" which will bring you to this line:

    return apply_filters('social_broadcasting_enabled_post_types', array('posts'));

    And then just change "posts" to whatever the name of your custom post types are. I was also able to add multiple post types to that function as well, such as:

    return apply_filters('social_broadcasting_enabled_post_types', array('posts','news'));

    The only difficulty might be finding out what your custom post types are actually named in the code.

  5. nijip
    Member
    Posted 2 years ago #

    Thanks, worked like a treat.
    For any one else out there the line of code to change is on line 664.

  6. Alex King
    Member
    Plugin Author

    Posted 2 years ago #

    Don't change the code, use the filter. The reason is is there is so you can make changes to functionality without changing the code (and having it break on upgrade, etc.) - just like WordPress core.

    http://codex.wordpress.org/Plugin_API#Filters

  7. greggo
    Member
    Posted 2 years ago #

    This filter seems to have been updated recently. It now reads:

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

    This includes my custom post types, but I'm still not getting any comments shown on them. I also tried to just change it to the code listed above without any luck.

  8. greggo
    Member
    Posted 2 years ago #

    My bad...it turns out I just needed to uncheck and recheck the "Allow people to post comments on new articles" setting to get it rolling for the custom post types.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags