If your code is the size of Wordpress, just use Wordpress and save yourself time.
What I have done is created entirely modularized code for Database integration. Adding, Retrieving, Deleting, Updating. Use PDO and prepared statements, this cuts down on the majority of pre and post processing you need to do via “code.” Also consider creating Views and Functions within your database itself whether that is Mysql, Postgress, Oracle or whatever. Let the database do the work for filtering and sorting content, that is what it is for. You do NOT need to do any of that in code at all, learn the features of your database and tell it to do the stuff you have been coding in PHP or whatever server side language you are using.
There is a great book on learning how to create Views and other more advanced things…
The Language of SQL by Larry Rockoff - Second Edition. This has saved me hundreds of lines of coding for things the database is designed to perform, just let it do it automatically and deliver the content in the form you need. You can do A LOT with little, really is a game changer when you learn to use the stack properly.
Let the database do all the filtering, sorting and content mixing how you want then retrieve the completed result. Simple to do and setup. Don’t over complicate things, learn the moderate and advanced techniques for the technologies you are using and it will actually save you time and effort in the short and long haul.
Learn SQL specifically Views, Stored Procedures and Sub Queries… It will change your life or at least allow you to do more than what you thought was possible while keeping your server side code small.