WP_Query and is_page_template() conditional

From the Codex (emphasis mine):

This Conditional Tag allows you to determine if you are in any page
template. Optionally checks if a specific Page Template is being used
in a Page. This is a boolean function, meaning it returns either TRUE
or FALSE. This tag must be used BEFORE The Loop and does not work
inside The Loop
(see Notes below).

http://codex.wordpress.org/Function_Reference/is_page_template

Your get_template_part(), and all the code it loads, is inside the Loop, so even if this works for you sometimes you are doing it wrong. I would suggest the solution offered in the Codex:

The function get_page_template_slug( $post_id ) will return the slug
of the currently assigned page template (or an empty string if no
template has been assigned – or false if the $post_id does not
correspond to an actual page). You can easily use this anywhere (in
The Loop, or outside) to determine whether any page has been assigned
a page template.

  // in the loop:
  if ( get_page_template_slug( get_the_ID() ) ){
     // Yep, this page has a page template
  }

That is, alter your code inside get_template_part('/templates/parts/format', $post_format); to use get_page_template_slug( get_the_ID() ).

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