programmatically create posts from files in a folder

At first you have to use readdir() in a while loop to get all pdf files. You should look at the examples on the readdir page to know how to use it.
Inside the loop you have to add the posts with the pdf files. Normally you would use wp_insert_attachment() to add files to your blog. But if you want a single post for each pdf which is shown on your homepage you have to use wp_insert_post(), where the argument “file” contains the path to the file. After adding the post (but also in the loop) you have to use the id, which comes back from wp_insert_post(), you have to add the category using wp_set_post_categories.

I could provide you the whole code to perform this task, but in my opinion it is better to learn it by writing the code yourself. If you have further questions don’t hesitate to ask.

error code: 523