How to check if a custom post type uses a custom template?

I mean “Full Width” like we do with pages : is_page_template( ‘Full
Width’ ) ?

  • is_page_template() does not accept a Template Name value like Full Width, but instead, a file name such as full-width.php or templates/full-width.php.

  • Secondly, is_page_template() can be used with any post types and not just Pages (page post type), so you can also use the function to check if your books post uses a specific template.

  • You can also or alternatively use get_page_template_slug() which is used internally by is_page_template(), like so, where the template resides within a theme sub-directory:

    // Note: In the loop, you'd use get_page_template_slug( get_the_ID() ).
    if ( is_singular( 'books' ) &&
        'templates/full-width.php' === get_page_template_slug()
    ) {
        // your code
    }
    

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)