if custom post type exist

I want to test if custom post type mobile exist. I used if custom post type exist in the loop, but it doesn't work. Any suggestion why my code is not working

?php /* The loop */ ?
?php if ( have_posts() ) : ?...

?php while ( have_posts() ) : the_post(); ?

? if( post_type_exists( 'mobiles' ) ) {  echo 'The Products post type   exists';} ?
?php get_template_part( 'content', get_post_format() ); ?

?pp echo 'The post type is: '. get_post_type( get_the_ID() ); ?

?php endwhile; ?
?php twentythirteen_paging_nav(); ?
?php else : ?
?php get_template_part( 'content', 'none' ); ?
?php endif; ?

Topic function-exists posts customization Wordpress

Category Web


You typed "mobiles" when you said you wanted to check for post type "mobile". So simply remove the s ;).

<? if( post_type_exists( 'mobiles' ) ) {  echo 'The Products post type   exists';} ?> 

Should be:

<? if( post_type_exists( 'mobile' ) ) {  echo 'The Mobile post type   exists';} ?>

If it's still not working, triple check if you succesfully registered a post type named "mobile".

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.