Searching Posts Programmatically in a WordPress Plugin

Per comments above from mmm

Try this

$posts = get_posts(["s" => "string to search"]); 

Also, Covering the get_posts API is a bit beyond a single StackExchange answer, but if you want to dive deep you’ll find more informations in the codex.

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