• Resolved capeleng

    (@capeleng)


    The Stellar Places plugin, is one of the few Google maps plugins that support custom post types. How would I add stellar-places-location to the list of Supports in the Settings drop-down?

    It would be great if these two plugins worked together!

    Here is how they define their CPT.

    const POST_TYPE = 'stlr_place';
    	/**
    	 * Register post type
    	 */
    	public static function register_post_type() {
    		$args = array(
    			'labels'      => array(
    				'name'               => __( 'Places', 'stellar-places' ),
    				'singular_name'      => __( 'Place', 'stellar-places' ),
    				'add_new_item'       => __( 'Add New Place', 'stellar-places' ),
    				'edit_item'          => __( 'Edit Place', 'stellar-places' ),
    				'new_item'           => __( 'New Place', 'stellar-places' ),
    				'view_item'          => __( 'View Place', 'stellar-places' ),
    				'search_items'       => __( 'Search Places', 'stellar-places' ),
    				'not_found'          => __( 'No places found', 'stellar-places' ),
    				'not_found_in_trash' => __( 'No places found in trash', 'stellar-places' ),
    			),
    			'has_archive' => true,
    			'public'      => true,
    			'supports'    => array(
    				'title',
    				'editor',
    				'excerpt',
    				'thumbnail',
    				'stellar-places-location',
    			),
    			'rewrite'     => array(
    				'slug' => 'locations',
    				'with_front' => false,
    			),
    			'taxonomies'  => array( Stellar_Places_Location_Category::TAXONOMY ),
    			'menu_icon'   => 'dashicons-location-alt',
    		);
    		$args = apply_filters( self::POST_TYPE . '-post_type_args', $args );
    		register_post_type( self::POST_TYPE, $args );
    	}

    https://wordpress.org/plugins/custom-post-type-ui/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter capeleng

    (@capeleng)

    The author of Stelar Places helped me out. Here is how to add support for any CPT created with Custom Post Type UI:

    add_action('init', 'add_stellar_places_post_type_support');
    function add_stellar_places_post_type_support() {
    	add_post_type_support( 'range', 'stellar-places-location' );
    }
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    While not the exact same, I do have the following new hook that would have been a help as well.

    /**
     * Filters custom supports parameters for 3rd party plugins.
     *
     * @since 1.0.0
     *
     * @param array  $value     Empty array to add supports keys to.
     * @param string $name      Post type slug being registered.
     * @param array  $post_type Array of post type arguments to be registered.
     */
    $user_supports_params = apply_filters( 'cptui_user_supports_params', array(), $post_type['name'], $post_type );

    It runs before the register_post_type call so that you could add it to as many as needed. Only caveat is that it’s not part of the stored option in the database, but that’s not a bad thing either.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘"Supports" list to include Stellar Places plugin’ is closed to new replies.