Forum Replies Created
Viewing 3 posts - 1 through 3 (of 3 total)
-
AuthorPosts
-
June 26, 2020 at 6:35 PM in reply to: โ How to display label of select advanced custom field? #20512
A. Kurniawan
ParticipantThank you, it works!
June 26, 2020 at 10:26 AM in reply to: โ How to display label of select advanced custom field? #20506A. Kurniawan
Participantadd_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' ); function your_prefix_register_meta_boxes( $meta_boxes ) { $prefix = ''; $meta_boxes[] = array ( 'title' => esc_html__( 'Server Specifications', 'text-domain' ), 'id' => 'server-specifications', 'post_types' => array( 0 => 'dedicated-server', ), 'context' => 'after_title', 'priority' => 'high', 'fields' => array( array ( 'id' => $prefix . 'cpu_model_06x5z89bthw', 'type' => 'post', 'name' => esc_html__( 'CPU Model', 'text-domain' ), 'post_type' => array( 0 => 'cpu', ), 'field_type' => 'select_advanced', 'required' => 1, 'after' => '<div class="addon-link">» <a href="post-new.php?post_type=cpu">Add new CPU</a></div>', ), array ( 'id' => $prefix . 'ram_rpvl3tynznp', 'type' => 'post', 'name' => esc_html__( 'RAM', 'text-domain' ), 'post_type' => array( 0 => 'ram', ), 'field_type' => 'select', 'query_args' => array( 'order' => 'ASC', ), 'required' => 1, 'after' => '<div class="addon-link">» <a href="post-new.php?post_type=ram">Add new RAM</a></div>', ), array ( 'id' => $prefix . 'drives_046wdfgugzub', 'type' => 'post', 'name' => esc_html__( 'Drives', 'text-domain' ), 'post_type' => array( 0 => 'drive', ), 'field_type' => 'select_advanced', 'required' => 1, 'after' => '<div class="addon-link">» <a href="post-new.php?post_type=drive">Add new drive</a></div>', 'multiple' => true, ), array ( 'id' => $prefix . 'price_14ab48oth3ih', 'type' => 'text', 'name' => esc_html__( 'Price', 'text-domain' ), 'desc' => esc_html__( 'Currency sign is not required', 'text-domain' ), 'placeholder' => esc_html__( 'xxx.xx', 'text-domain' ), 'required' => 1, 'label_description' => esc_html__( 'Regular price', 'text-domain' ), ), array ( 'id' => $prefix . 'featured_aaljhych5q', 'type' => 'switch', 'name' => esc_html__( 'Featured', 'text-domain' ), 'style' => 'rounded', 'on_label' => 'Yes', 'off_label' => 'No', 'label_description' => esc_html__( 'Whether item is featured', 'text-domain' ), ), array ( 'id' => $prefix . 'onsale_pn2jn0x6aw', 'type' => 'switch', 'name' => esc_html__( 'On Sale', 'text-domain' ), 'style' => 'rounded', 'on_label' => 'Yes', 'off_label' => 'No', 'label_description' => esc_html__( 'Whether item is on sale or discounted', 'text-domain' ), ), array ( 'id' => $prefix . 'discounted_ye8xr7m539i', 'type' => 'text', 'name' => esc_html__( 'Discounted Price', 'text-domain' ), 'placeholder' => esc_html__( 'xxx.xx', 'text-domain' ), 'label_description' => esc_html__( 'Price after discount', 'text-domain' ), 'visible' => array( 'when' => array( array ( 0 => 'onsale_pn2jn0x6aw', 1 => '=', 2 => 1, ), ), 'relation' => 'and', ), ), array ( 'id' => $prefix . 'recommended_63mxmfmup4t', 'type' => 'switch', 'name' => esc_html__( 'Recommended', 'text-domain' ), 'style' => 'rounded', 'on_label' => 'Yes', 'off_label' => 'No', 'label_description' => esc_html__( 'For home page', 'text-domain' ), ), array ( 'id' => $prefix . 'order_url_3hdpmvlrlhd', 'type' => 'url', 'name' => esc_html__( 'Order URL', 'text-domain' ), 'placeholder' => esc_html__( 'https://yourdomain.com/?url=something', 'text-domain' ), 'required' => 1, ), ), ); return $meta_boxes; }Actually it's not just
select_advanced, but also the one that usingselectif( is_home() && is_front_page() ) { // The Query $the_query = new WP_Query( array( 'post_type' => 'dedicated-server', 'posts_per_page' => 1 ) ); // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $recommend = rwmb_meta('recommended_63mxmfmup4t'); if($recommend == 1 || $recommend == 'Yes') { ?> <?php <!--- other tags ... --> <h5 class="h5-z5-1"><?php rwmb_the_value('cpu_model_06x5z89bthw');?> <!--- other tags ... --> <?php } } } else { // no posts found } /* Restore original Post Data */ wp_reset_postdata(); } ?>June 26, 2020 at 9:48 AM in reply to: โ How to display label of select advanced custom field? #20504A. Kurniawan
ParticipantWeird, on my installation it's always wrap with
<a></a>, so I always make a link when displaying the label. -
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)