Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Andy Mercer

    (@kelderic)

    Hey, I should have documented this in the Description, but you can do this easily already. Add this code to your theme’s function.php file:

    function add_featured_galleries_to_ctp( $post_types ) {
    	return array( 'ctp_slug' );
    }
    add_action( 'fg_post_types', 'add_featured_galleries_to_ctp' );

    The fg_post_types is an action you can hook into to add your CTP to the list of types that Featured Galleries appear on.

    Thread Starter xjoex93

    (@xjoex93)

    I added the code my to theme’s function.php file but it doesn’t seem to work. I’m not very advanced in coding which is why I bought a theme. Am I suppose to modify the code to suit my theme?

    Plugin Author Andy Mercer

    (@kelderic)

    If you add that code to the functions.php file, it will appear on whatever CTP you have specified. In the example above, it would appear on a theme with the ID ctp_slug. You can specify multiple CTPs since it is returning an array.

    Note, this will make the box appear in the backend. The theme will have to build the presentation into any templates, just like themes have to build featured images in. If you purchased a theme which isn’t built with Featured Galleries in mind, you’ll have to do it yourself.

    I’d suggest putting a conditional on there if the post types are registered via a plugin (which is the most standards-compliant way of doing post types – keeps them independent of your theme). Something like this:

    function add_featured_galleries_to_ctp( $post_types ) {
    	$fg_post_types = array(); // you could add 'post' and/or 'page' to this array if you would like them to stay, or change it to $post_types to build off the already included post types
    
    	if( post_type_exists( 'ctp_slug' ) )
    		$fg_post_types[] = 'ctp_slug';
    
    	return $fg_post_types;
    }
    add_action( 'fg_post_types', 'add_featured_galleries_to_ctp' );

    This would just protect from potential errors if the custom post type no longer exists when a plugin is deactivated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Compatible with all Post Types?’ is closed to new replies.