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. Modernizing WordPress Development with Sage 9: Part 3 - Fresh Consulting
  2. https://discourse.roots.io/t/custom-post-types-in-loop/11257/8?u=bhanu_kumar_singh
  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 https://discourse.roots.io/t/custom-post-types-in-loop/11257/8 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.