Astra_Breadcrumb_Trail::get_post_types_by_slug( int $slug )

Gets post types by slug. This is needed because the get_post_types() function doesn’t exactly match the ‘has_archive’ argument when it’s set as a string instead of a boolean.


Description


Parameters

$slug

(int) (Required) The post type archive slug to search for.


Return

(void)


Source

File: inc/addons/breadcrumbs/class-astra-breadcrumb-trail.php

	protected function get_post_types_by_slug( $slug ) {

		$return = array();

		$post_types = get_post_types( array(), 'objects' );

		foreach ( $post_types as $type ) {

			if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) ) {
				$return[] = $type;
			}
		}

		return $return;
	}

Changelog

Changelog
Version Description
0.6.0 Introduced.


User Contributed Notes

You must log in before being able to contribute a note or feedback.