Custom Fields
Re-Envisioned
Support MB Custom Taxonomy Taxonomy and custom table

  • Creator
    Topic
  • #29000
    gparsec@gmail.com
    Participant

    WP Grid Builder use Meta Box function to output custom value.
    It is Meta Box that output content like that. It does not take into account selected order.
    For example, if you try with the Meta Box shortcode in Raw Content block of the card builder, you will have the same result: [rwmb_meta id="field_id" object_id="{{ post.id }}"]
    And, when I debug Meta Box, it always returns the taxonomy terms in alphabetical order.

    taxonomy is hierarchical
    Can you provide solution
    thank you

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #29008
    Long Nguyen
    Moderator
    #29013
    gparsec@gmail.com
    Participant

    The developer of WP Grid Builder uses the Meatabox function "rwmb_the_value" to retrieve data from the custom table that is part of the advanced taxonomy in (hierarchical) order. The data in the database is stored that way aswell.
    can you investigate the metabox function how it behaves under those conditions as
    data is in (hierarchical) order
    raw data is in alphabetical order using the meatabox "rwmb_the_value" function, as it appears that the metabox function is not taking in consideration the structure of the raw data

    the below ling it refers to taxonomies that are (non-hierarchical) in the order
    https://metabox.io/support/topic/custom-taxonomy-sorting/
    thank you

    #29018
    Long Nguyen
    Moderator

    Hi,

    Thanks for your additional information.

    The function of WordPress get_terms() also does not support to retrieve all terms with hierarchical order. You can get the parent term then get the child term after. For example:

    $terms = rwmb_meta( 'taxonomy_advanced', ['storage_type' => 'custom_table', 'table' => 'my_custom_table', 'parent'=> false] );
    
    foreach ( $terms as $term ) {
        $subterms = get_terms( array(
            'taxonomy' => 'category',
            'parent'   => $term->term_id,
            'hide_empty' => false
        ));
        foreach ( $subterms as $subterm ) {
            echo $subterm->term_id;
        }
    }

    taxonomy_advanced is the field ID, my_custom_table is the custom table name, category is the taxonomy slug.

    I will inform the development team to support this case by using the helper function in future updates.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.