Custom Fields
Re-Envisioned
Support General Add Select Values from Other Custom Fields

This topic contains 13 replies, has 2 voices, and was last updated by  Anh Tran 3 months ago.

  • Creator
    Topic
  • #12512
    Resolved
    Pete Wlodkowski
    Participant

    Hi, I have a few custom number fields, created in Advanced Custom Fields and assigned to my custom post type.

    I want to populate a Meta Box select field on the same custom post type from these values.

    So, I have the following number / text fields, each with a single value, ex: 40

    field_1
    field_2
    field_3
    field_4

    I want to use these as the value options / select options for my meta box select field.

    How might I achieve this?

Viewing 3 replies - 11 through 13 (of 13 total)
  • Author
    Replies
  • #12689

    Pete Wlodkowski
    Participant

    Anh Tran, you are awesome my friend. I send a lot of gratitude and karma your way! You deserve it. Thank you for helping me on this. Happy Holiday.

    #12711

    Pete Wlodkowski
    Participant

    Hi Anh,

    Quick question. I’ve set up individual groups for multiple years (2006 – 2019), but it is very slow:

    2006 - 20019 year grouping

    Here is my working code for the multi years, wondering if there is a better way to write it so it is quicker. Like I said, this is slow. It’s taking forever to load the edit Tournament (edit post).

    https://ghostbin.com/paste/ejjhy

    Thought maybe the multi year functions could be grouped… just wasn’t sure. Thought I’d send you a message. Thank you!

    #12737

    Anh Tran
    Keymaster

    I have optimized your code to make it much shorter here: https://ghostbin.com/paste/uk3zq. As all the year has a same meta box, it can be wrapped in a function.

    However, the speed is slow maybe because of the post field. Each post field make a query to the database to get all posts. As you have 14 post fields for 14 years, there are 14 queries. That might be the cause.

    Update: I have updated the plugin on Github https://github.com/wpmetabox/meta-box/ that has an improvement for the post field. Now it runs only 1 query instead of 14. Please download from Github and try it.

Viewing 3 replies - 11 through 13 (of 13 total)

You must be logged in to reply to this topic.