Getting list of Categories for Custom Post Types

I see you edited your post, did you get it to work for that first part?

now for your edit, you need to give more context. I am able to get the archive link and content using that function. Most likely, you have another code or customization that is conflicting with this function in your setup.

I would check

  • The post type has the has_archive args is set to true.
  • Flush the rewrite rules to make sure they are clean.
  • Look at the timing of your hook call to make sure it is called after your post type is setup

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