Understanding controller for a custom post type

I am a little new to the whole MVC method but I have read a lot about its pros and am really interested in following it because I have faced a lot of problems with my cowboy style of code in WordPress.

Problem Statement

I have a custom post tyle faq which has a certain custom field. [I use toolset to create custom posts and fields. I have been using it for a while and it does the job well. I see people using ACF here, I will be looking into that after this project ].

According to the design.

  1. I have to include a section on the Frontend which would display some of the posts of FAQ on the section with some logic.
  2. There will be another page where I have to show all of the faqs.

Now I have read multiple articles and discussions on how to use controllers on sage.

  1. https://www.freshconsulting.com/modernizing-wordpress-development-with-sage-9-part-3/
  2. Custom Post Types in loop
  3. https://github.com/soberwp/controller#usage

Now the confusion I have in here is that I read,

You should not repeat your methods. DRY

Now according to the answer by @alwaysblank Custom Post Types in loop here.

There is a method gallery_loop which is in the class FrontPage. Now if I replace my faq with gallery loop then I will have to have a method in Faq class which would almost do the same and thus brake the DRY principle. Is it so? Or I am totally understanding this wrong?

I am just interested in knowing what is the best & correct way to do this. :smile:

This topic was automatically closed after 42 days. New replies are no longer allowed.