Global $post shows null in some of my custom post types archive pages

The global $post object represents the current post within The Loop and is created by the the_post() function. It enables functions like the_title(), the_content() etc. to show the title and content for the current post without needing to pass IDs or anything.

This is why a post type archive doesn’t have a $post object set when you’re enqueuing scripts. Why would it? What post would it represent? What would $post->post_author be for a post type archive? It doesn’t make sense to have one because an archive is not a post.

The correct solution is the one you found: The is_post_type_archive() function. Under the hood it checks the main Query to see if it is for the archive for a post type.

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