Support Forum » User Profile

Forum Replies Created

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • AndrewAndrew
    Participant

    Further to this I have this code that shows the select list in my product CPT but the list is empty:

    add_filter( 'rwmb_meta_boxes', 'register_custom_meta_boxes' ); // Hook into Meta Box to register custom meta boxes
    
    function register_custom_meta_boxes( $meta_boxes ) {
        // Retrieve stored values from the settings page field
        $options = get_option( 'prod_cats_test', [] ); // Replace with the actual field key inside your settings page
    
        // Ensure values are correctly formatted before populating the select field
        if ( is_array( $options ) && !empty( $options ) ) {
            $formatted_options = array_combine( $options, $options ); // Convert array into key-value pairs for the select field
        } else {
            $formatted_options = []; // Fallback to an empty array to prevent errors
        }
    
        // Define the custom meta box for the specific post type
        $meta_boxes[] = [
            'title'      => 'Product Categories', // Title of the meta box
            'id'         => 'custom_select_meta_box', // Unique ID for the meta box
            'post_types' => ['product'], // Specify the post type(s) where this meta box should appear
            'fields'     => [
                [
                    'id'      => 'product_cats', // Field ID for storing the selection
                    'name'    => 'Select an Option', // Label for the select field
                    'type'    => 'select', // Define the field type as a dropdown select box
                    'options' => $formatted_options, // Populate dropdown dynamically
                ],
            ],
        ];
    
        return $meta_boxes; // Return the modified array of meta boxes for registration
    }
    in reply to: Get file url in template #46069
    AndrewAndrew
    Participant

    Hi Peter,

    Thank you for that, it worked perfectly.

    in reply to: Get file url in template #46014
    AndrewAndrew
    Participant

    Sorry this is the code snippet:

    <?php $files = rwmb_meta( 'fees_file_upload' ); ?>
    <h3>Uploaded files</h3>
    <ul>
        <?php foreach ( $files as $file ) : ?>
            <li><a href="<?= $file['url']; ?>"><?= $file['name']; ?></a></li>
        <?php endforeach ?>
    </ul>
    in reply to: Relationship not bi-directional #45660
    AndrewAndrew
    Participant
    in reply to: Relationship not bi-directional #45659
    AndrewAndrew
    Participant

    null

    in reply to: Relationship not bi-directional #45658
    AndrewAndrew
    Participant

    Hi Anh, apologies for the delay getting back to you. Here is a screenshot of the relationship set up.

    Meta Box relationship

    in reply to: Get Single Image URL #44539
    AndrewAndrew
    Participant

    Think I've worked it out thanks

    in reply to: Get Single Image URL #44538
    AndrewAndrew
    Participant

    I managed to get the image via the ID.

    If I'm using a loop like this <?php foreach($teams as $p): ?> and while in the loop I use get_permalink() it gets the permalink of the parent post instead of the current post in the loop. How would I get the permalink of the current post in the loop?

    in reply to: Relationship order in Oxygen repeater #44529
    AndrewAndrew
    Participant

    Hi Peter, yes I managed to use the api in a code block and that worked as desired. Was hoping to be able to use the Oxygen repeater to do this but this seems like a limitation of either Oxygen or me.

    in reply to: Relationship order in Oxygen repeater #44518
    AndrewAndrew
    Participant

    Looks like they are ordering based on what team-members are set in the cpt rather than the order they are set in the relationship.

    in reply to: Show custom fields metabox on specific page only #35187
    AndrewAndrew
    Participant

    Thanks for this. It worked perfectly 🙂

    in reply to: Show only if field not blank #29943
    AndrewAndrew
    Participant

    Hi Long,

    Got it working thanks to your advise. Thank you very much.

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