meta-box icon indicating copy to clipboard operation
meta-box copied to clipboard

How to show taxonomy value and clone option value or image?

Open athossin opened this issue 9 years ago • 1 comments

Dear sir, Thanks for this awesome plugin.I am using this plugin for making some metabox.I have a metabox with ID pb_event_status_away which has different options like Goal, Own goal etc. I have used following codes to registered this metabox.

array(
                    'name'              => __( 'Event Type', 'themepixels' ),
                    'id'                => "{$prefix}event_status_away",
                    'type'              => 'select_advanced',
                    'options'           => array(
                        'goal'          => __( 'Goal', 'themepixels' ),
                        'owngoal'       => __( 'Own Goal', 'themepixels' ),
                        'yellow'        => __( 'Yellow Card', 'themepixels' ),
                        'red'           => __( 'Red Card', 'themepixels' ),
                        'substitutionin' => __( 'Substitution In', 'themepixels' ),
                        'substitutionout' => __( 'Substitution Out', 'themepixels' ),
                        'pen'              => __( 'Penalty', 'themepixels' ),
                        'pensave'        => __( 'Penalty Saved', 'themepixels' ),

                    ),
                    'placeholder'       => __( 'Select Event Type', 'themepixels' ),
                    'multiple'          => false,
                    'clone'           => 'true',
                ),

When I am trying to show or echo out the content like Goal, Penalty ect. using following codes then it shows id such as goal,owngoal instead of value Goal, Own Goal ,of the respective option .How to solve the problem?Second Question:Can I show Image (goal image, own goal image etc)instead of option's value like Goal, Penalty, Own Goal

<?php              
        $event_status_away = rwmb_meta( 'pb_event_status_away'); ?>
                  <?php 
                   foreach ( $event_status_away as $event_status_name_away ){?>
                    <li role="presentation">
                   <?php  echo $event_status_name_away; ?>
                   </li>
               <?php } 
      ?>

Final Problem: I am using following codes to show selected taxonomy name but it show

“Xdebug: Catchable fatal error: Object of class WP_Term could not be converted to string in C:\wamp\www\wordpress\wp-content\themes\testtheme\content-parts\content-fixture.php on line 34. Output triggered in C:\wamp\www\wordpress\wp-content\plugins\query-monitor\collectors\php_errors.php on line 157

array(
                    'name'              => __( 'Select Venue', 'themepixels' ),
                    'id'                => "{$prefix}match_venue_cats",
                    'type'              => 'taxonomy',
                    'options'           => array(
                        'taxonomy'      => 'venue',
                        'type'          => 'select_advanced',
                        'args'          => array()
                    ),
                    'multiple'          => false,
                ),

Frontend code:

 $terms = rwmb_meta( 'pb_match_venue_cats' );
        if ( !empty( $terms ) ) {
            $content = '<ul>';
            foreach ( $terms as $term ) {
                $content .= sprintf(
                    '<li><a href="%s" title="%s">%s</a></li>',
                    get_term_link( $term, 'venue' ),
                    $term->name,
                    $term->name
                );
            }
            $content .= '</ul>';
            echo $content;
        }

Thanks Arif

athossin avatar Sep 16 '16 14:09 athossin

What is line 34?

funkatron82 avatar Oct 04 '16 03:10 funkatron82