Support Forum » User Profile

Forum Replies Created

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • in reply to: Post field: how to filter posts of certain categories? #31814
    dhuydhuy
    Participant

    Just some simple lines of code to make my life easier.
    Thanks for your swift respond.

    in reply to: picture tag disappear after udating to 5.2.3 #17413
    dhuydhuy
    Participant

    It's OK now. Thanks for your swift respond.
    Cheers.

    in reply to: Display CPT in page #11750
    dhuydhuy
    Participant

    Everything is OK now.
    Smooth migration from ACF.

    in reply to: Display CPT in page #11670
    dhuydhuy
    Participant

    I put all the code in a function outside the main function, then call it, yet nothing happens.

    // Sub function
    function pt() {
      $table = isset( $pricing['pricing_table_id'] ) ? $pricing['pricing_table_id'] : '';
      if ( $table ) { 
      $plans = rwmb_meta( 'plan', '', $table );
        if ( ! empty( $plans ) ) {
          foreach ($plans as $plan) {
            $name = isset( $plan['plan_name'] ) ? $plan['plan_name'] : '';
            echo $name;
          }
        }
      }
    }
    
    //Main function
    function page_section() {
      $sections = rwmb_meta( 'section' );
      if( ! empty( $sections ) ) {
        foreach ( $sections as $section ) {
          if($section == 'pricing') { pt() }
        }
      }
    }
    in reply to: Display CPT in page #11645
    dhuydhuy
    Participant

    It works like a charm!
    Another question, I'm working with template page.php, in which there are many modules such as pricing tables, FAQs, features,... For better organization, I put each module in separate files which are located in different folder. Then, in the page.php, I just call the function for respective module.
    Problem is value in fields cannot be retrieved, all none whilst html output is OK. Please correct me if missed anything.
    Image

    in reply to: Display CPT in page #11641
    dhuydhuy
    Participant

    At last, it's OK now.

    in reply to: Display CPT in page #11640
    dhuydhuy
    Participant

    Thanks for your swift respond.
    Strangely, it still doesn't work.

    in reply to: Display CPT in page #11630
    dhuydhuy
    Participant

    Below is the meta box of the page builder. I can select the Pricing table (CPT) via the post field. I'm stuck at pulling the meta boxes from the selected CPT.

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array (
            'title' => 'Page',
            'id' => 'page',
            'post_types' => array(
                'page',
            ),
            'context' => 'after_title',
            'priority' => 'high',
            'fields' => array(
                
                array (
                    'id' => 'section',
                    'type' => 'group',
                    'name' => 'Section builder',
                    'fields' => 
                    array (
                        0 => 
                        array (
                            'id' => 'section_pricing',
                            'type' => 'group',
                            'name' => 'Pricing',
                            'fields' => 
                            array (
                                0 => 
                                array (
                                    'id' => 'pricing_table_id',
                                    'type' => 'post',
                                    'name' => 'Post',
                                    'post_type' => 
                                    array (
                                        0 => 'prices',
                                    ),
                                    'field_type' => 'select_advanced',
                                ),
                            ),
                            'default_state' => 'collapsed',
                            'groupfield' => 'text',
                            'collapsible' => true,
                            'visible' => true
                        ),
                        
                    ),
                    'clone' => 1,
                    'sort_clone' => 1,
                    'default_state' => 'collapsed',
                    'collapsible' => true,
                    'save_state' => true,
                    'add_button' => 'Add section',
                ),
            ),
            'style' => 'seamless',
        );
        return $meta_boxes;
    }

    Meta boxes of CPT:

    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $meta_boxes[] = array (
            'title' => 'Pricing table',
            'id' => 'pricing-table',
            'post_types' => array(
                'prices',
            ),
            'context' => 'after_title',
            'priority' => 'high',
            'fields' => array(
                
                array (
                    'id' => 'plan',
                    'type' => 'group',
                    'name' => 'Group',
                    'fields' => 
                    array (
                        0 => 
                        array (
                            'id' => 'plan_class',
                            'type' => 'text',
                            'name' => 'Class',
                        ),
                        1 => 
                        array (
                            'id' => 'plan_name',
                            'type' => 'text',
                            'name' => 'Name',
                        ),                  
                    ),
                    'clone' => 1,
                    'default_state' => 'collapsed',
                    'collapsible' => true,
                    'add_button' => 'Add table',
                    'group_title' => 'Table',
                ),
            ),
            'style' => 'seamless',
        );
        return $meta_boxes;
    }
    in reply to: Display CPT in page #11627
    dhuydhuy
    Participant

    Yes, the ultimate goal is getting meta boxes of the post object.

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