Exclude some posts from displaying in wp_query based on some condition

To have the pagination work properly you need to filter the posts at the WordPress main query level using the pre_get_posts action.

By looking at your code, I don’t see where the post specific information is involved. Is $course_options holding information for the post?

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