GithubHelp home page GithubHelp logo

Comments (3)

jlambe avatar jlambe commented on July 28, 2024

Hi and thanks for trying the framework.

Actually you don't need to create a custom field in order to build relationships between custom post types. You can easily do it with a very small amount of code.

I invite you to check the code of the framework website here on Github as we've built a select field filled with page posts (which can easily be replaced by custom post types):

Take a look at this file home.php around line 21 to 26:

As you can see, there is a call to Field::select() and we pass an array filled by a custom model (a PageModel class that retrieve/update datas).

Then look at the code inside the PageModel class for the PageSelection method. We simply run a new WP_Query and return an array where each key is the ID and the value is the post_title:

Then you get a custom relationship field with better logic separation and the model class and its methods can easily be re-use anywhere in your application ;)

Also I checked your code and at this state, I will reject your pull request because:

  1. What you're looking for can easily be achieved like the example above.
  2. You hardcoded a listing custom post type and this is not giving any flexibility for developers.

For your project, please check the website code and if you need more help or more information, don't hesitate to ask ;)

Regards,

Julien

from framework.

iamkevingreen avatar iamkevingreen commented on July 28, 2024

:) I knew there had to be a better way to go about it. I also intended on cleaning it up. Thanks this is awesome and super helpful. Long live themosis.

-thanks

from framework.

ThinkDevStudios avatar ThinkDevStudios commented on July 28, 2024

Hi! I can't seem to view the code for building a relationship field. The website repo seems to have been deleted already. How do you make a relationship field?

from framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.