• Resolved Nexxoz

    (@nexxoz)


    I needed this to work with some of my post types, this is not recommended but more an ide.

    Go to plugins/wp-subtitle and open wp-subtitle.php with your favorit text editor.

    Add this function inside the WPSubtitle class

    
           /**
    	* Get Post Types
    	* By Nexxoz.com
    	*/
    	public static function _get_tax_types(){
    		$taxonomies = get_post_types( '', 'names' ); 
    		unset($taxonomies['attachment']);
    		unset($taxonomies['revision']);
    		unset($taxonomies['nav_menu_item']);
    		unset($taxonomies['wpcf7_contact_form']);
    		unset($taxonomies['guide']);
    		return $taxonomies;
    	}
    
    

    Now find _add_default_post_type_support function and replace it with this

    
    	public static function _add_default_post_type_support() {
    		// add_post_type_support( 'page', 'wps_subtitle' );
    		// add_post_type_support( 'post', 'wps_subtitle' );
    		foreach (self::_get_tax_types()  as $taxonomy ) {
    			add_post_type_support($taxonomy, 'wps_subtitle' );
    		}
    	}
    

    Now find get_supported_post_types function and replace this line

    
    $post_types = array_merge( $post_types, array( 'post' , 'page' ) );
    

    with this

    
    $post_types = array_merge( $post_types, self::_get_tax_types() );
    

    Save the file and upload it, Happy coding ??

Viewing 1 replies (of 1 total)
  • Plugin Author Ben Huson

    (@husobj)

    It’s possible to add support for post types without hacking the plugin.

    You can add support to your theme as follows – add this to your theme’s functions.php file.

    
    <?php
    function mytheme_add_wps_subtitle_event_support() {
        add_post_type_support( 'my_post_type', 'wps_subtitle' );
    }
    add_action( 'init', 'mytheme_add_wps_subtitle_event_support' );
    ?>
    

    So, if you want to add support for multiple post types, you can get all post types using get_post_types() as mentioned above, and loop through them using add_post_type_support() to add support for each.

    • This reply was modified 8 years, 2 months ago by Ben Huson.
Viewing 1 replies (of 1 total)
  • The topic ‘Tip: Make WPSubtitle work with post types’ is closed to new replies.