douminfu8033 2013-09-27 22:24
浏览 23

小部件中的自定义帖子元未显示

I am making a custom post widget thats linkt to custom post type reviews with information as boxart, dev, publicer but it won't show. Can someone tell me whate i do wrong?

Its looking like the request is not possible in widget in the singel.php is it working but not in the other widget file.

<?php
/**
* Plugin Name: Custom review informatio Widget
*/

add_action( 'widgets_init', 'box_review_load_widgets' );

function box_review_load_widgets() {
register_widget( 'BOX_Review_Widget' );
}

class BOX_review_Widget extends WP_Widget {

/**
 * Widget setup.
 */
function BOX_Review_Widget() {
    /* Widget settings. */
    $widget_ops = array( 'classname' => 'box_review_widget', 'description' => __('Laat meer informatie over de game zien', 'box_review_widget') );

    /* Widget control settings. */
    $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'box_review_widget' );

    /* Create the widget. */
    $this->WP_Widget( 'box_review_widget', __('Box: Review informatie', 'box_review_widget'), $widget_ops, $control_ops );
}

/**
 * How to display the widget on the screen.
 */
function widget( $args, $instance, $gameinfo, $reviewinfo ) {
    extract( $args );

    /* Our variables from the widget settings. */
    $title = apply_filters('widget_title', $instance['title'] );
    /* Before widget (defined by themes). */
    echo $before_widget;

    /* Display the widget title if one was input (before and after defined by themes). */
    if ( $title )
        echo $before_title . $title . $after_title;

                        ?>

        <div class="side-item">

                      <?php
  function curPageURL() {
  $pageURL = 'http';
 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 $pageURL .=     $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
   } else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  }
  return $pageURL;
   }
          ?>

            <?php               
            $reviewinfo = get_post_meta($post->ID, 'gamebox', true);
          foreach ($reviewinfo as $gameinfo ){ 

  echo '<center><img src="' . $gameinfo['boxart'] . '" width="200" border="4" /></center><br />';
  echo '<div class="fb-like" data-href="';
  echo curPageURL() ; 
  echo '" data-send="false" data-width="283" data-show-faces="false"></div>';
echo '<strong>Genre: </strong>' . $gameinfo['genre'] . '<br />';
echo '<strong>Releasedatum: </strong>' . $gameinfo['releasedatum'] . '<br />';
echo '<strong>Franchise: </strong>' . $gameinfo['franchise'] . '<br />';
echo '<strong>Ontwikkelaar: </strong>' . $gameinfo['ontwikkelaar'] . '<br />';
echo '<strong>Uitgever: </strong>' . $gameinfo['uitgever'] . '<br />';
echo '<strong>Beschikbaar op: </strong><br />' . $gameinfo['beschikbaar-op'] . '<br />';
echo '<strong>PEGI: </strong>' . $gameinfo['pegi'] . '<br />';
                             } 
                        ?>

          </p>              

        </div>

    <?php

    /* After widget (defined by themes). */
    echo $after_widget;
}

/**
 * Update the widget settings.
 */
function update( $new_instance, $old_instance ) {
    $instance = $old_instance;

    /* Strip tags for title and name to remove HTML (important for text inputs). */
    $instance['title'] = strip_tags( $new_instance['title'] );

    return $instance;
}


function form( $instance ) {

    /* Set up some default widget settings. */
    $defaults = array( 'title' => __('Game Informatie'));
    $instance = wp_parse_args( (array) $instance, $defaults ); ?>

    <!-- Widget Title: Text Input -->
    <p>
        <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'hybrid'); ?></label>
        <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:90%;" />
    </p>



<?php
}
    }
    ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)