Support

Account

Home Forums General Issues Taxonomy for custom field group

Solved

Taxonomy for custom field group

  • I inherited a site from a previous administrator, and I am having trouble with a custom field that he created.

    The following code is a snippet of a register_custom_group:

    `array (
    ‘key’ => ‘field_5619e8582fa74’,
    ‘label’ => ‘Link’,
    ‘name’ => ‘link’,
    ‘type’ => ‘page_link’,
    ‘column_width’ => ”,
    ‘post_type’ => array (
    0 => ‘game’,
    ),
    ‘allow_null’ => 1,
    ‘multiple’ => 0,
    ),
    `

    Here is the problem: I need to add a taxonomy parameter (category) to this custom field so that it limits the number of posts that are included in this select. I’ve tried many times, but I do not know how to properly code it.

    For example: My post type is ‘game’, and I need to limit it to say a category of ‘baseball’.

    Thanks in advance for any assistance.

  • Hi @bosoxbill

    You need to add the taxonomy option so it looks like this:

    'post_type' => array (
        0 => 'game',
    ),
    'taxonomy' => array (
        0 => 'taxonomy_name:term_name',
    ),

    Where “taxonomy_name” is the name of the taxonomy and “term_name” is the name of the term (baseball).

    If you want, you can always create a Page Link field from the backend and export it to PHP code from “Custom Fields > Tools” (PRO version) or “Custom Fields > Export” (Free version). That way you can see the code layout you need to update your code.

    I hope this helps 🙂

  • I can’t thank you enough. You’re a livesaver. That export php code is a handy trick.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Taxonomy for custom field group’ is closed to new replies.