rwmb-get-object-fields before initialisation of wordpress

Support MB Custom Table rwmb-get-object-fields before initialisation of wordpressResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #33491
    Nicholas CoxNicholas Cox
    Participant

    Hi

    I am creating my own meta queries to hook into wp_query to lookup custom tables and join them so i can perform advanced search queries and some JOINS etc and I am doing so using pre get posts.

    e.g. of a custom function im working on (still in early development stage), I am passing custom tables and returning them along with the post queries. Works well so far but the next step is to check against the field settings in the metabox fields setup.

    
    $args = array(
        'post_type'       => 'product',
        'posts_per_page'  => 10,
        'post_status'       => 'publish',
        'order_by'        => 'published_date',
        'order'               => 'ASC',
        'metabox'         => [
            [
                'table'   => $wpdb->prefix . 'dc_products',
                'order_by'  => 'end_date',
                'order'   => 'DESC',
                'fields'      => ['type', 'description', 'price', 'condition', 'location', 'end_date', 'images'],
            ],
        ],
    );
    

    I am looking for a way to get the meta box object fields but realised that I can only get the during initialisation of Woordpress which doesn't work for my script as it runs before initialisation.
    https://docs.metabox.io/rwmb-get-object-fields/

    
    $meta_box_registry = rwmb_get_registry( 'meta_box' );
    $field = rwmb_get_field_settings( $field_id );
    

    Is there any other way I can get the object fields before initialisation? I have a feeling I will not be able to, but worth asking.

    #33500
    Long NguyenLong Nguyen
    Moderator

    Hi,

    The helper function rwmb_***() works only when the field is already registered. In Meta Box, fields are registered at hook init with priority 20. So, you need to run the helper function after that.

    #33511
    Nicholas CoxNicholas Cox
    Participant

    Hi Long,

    Ok thanks anyway.

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