Kann mir keiner weiterhelfen?
Beiträge von WP-Click
-
-
Hallo zusammen,
ich habe ein gekauftes Template und möchte in das Widget my-recent-posts ein benutzerdefiniertes Feld hinzufügen, welches den Fotografen zum Bild ausliest.
Die Datei my-recent-posts sieht momentan so aus:
PHP
Alles anzeigen<?php // =============================== My Recent Posts (News widget) ====================================== class MY_PostWidget extends WP_Widget { /** constructor */ function MY_PostWidget() { parent::WP_Widget(false, $name = 'My - Recent Posts'); } /** @see WP_Widget::widget */ function widget($args, $instance) { extract( $args ); $title = apply_filters('widget_title', $instance['title']); $category = apply_filters('widget_category', $instance['category']); $linktext = apply_filters('widget_linktext', $instance['linktext']); $linkurl = apply_filters('widget_linkurl', $instance['linkurl']); $count = apply_filters('widget_count', $instance['count']); ?> <?php echo $before_widget; ?> <?php if ( $title ) echo $before_title . $title . $after_title; ?> <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); ?> <ul class="latestpost"> <?php $querycat = $category; ?> <?php $wp_query->query("showposts=". $count ."&category_name=". $querycat); ?> <?php if ($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();?> <li> <h5><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h5> <div class="thumbnail"> <a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?><strong></strong></a> <em></em> </div> <div class="link"><a style="margin-left: 46px;font-weight:normal;font-size:12px;" href="<?php the_permalink() ?>"><?php _e('mehr Informationen ', 'theme1473'); ?></a></div> </li> <?php endwhile; ?> </ul> <?php endif; ?> <?php $wp_query = null; $wp_query = $temp;?> <!-- Link under post cycle --> <?php if($linkurl !=""){?> <div class="link-1"><a href="<?php echo $linkurl; ?>"><?php echo $linktext; ?></a></div> <?php } ?> <?php echo $after_widget; ?> <?php } /** @see WP_Widget::update */ function update($new_instance, $old_instance) { return $new_instance; } /** @see WP_Widget::form */ function form($instance) { $title = esc_attr($instance['title']); $category = esc_attr($instance['category']); $linktext = esc_attr($instance['linktext']); $linkurl = esc_attr($instance['linkurl']); $count = esc_attr($instance['count']); ?> <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:', 'theme1473'); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $title; ?>" /></label></p> <p><label for="<?php echo $this->get_field_id('category'); ?>"><?php _e('Category Slug:', 'theme1473'); ?> <input class="widefat" id="<?php echo $this->get_field_id('category'); ?>" name="<?php echo $this->get_field_name('category'); ?>" type="text" value="<?php echo $category; ?>" /></label></p> <p><label for="<?php echo $this->get_field_id('count'); ?>"><?php _e('Posts per page:'); ?><input class="widefat" style="width:30px; display:block; text-align:center" id="<?php echo $this->get_field_id('count'); ?>" name="<?php echo $this->get_field_name('count'); ?>" type="text" value="<?php echo $count; ?>" /></label></p> <p><label for="<?php echo $this->get_field_id('linktext'); ?>"><?php _e('Link Text:', 'theme1473'); ?> <input class="widefat" id="<?php echo $this->get_field_id('linktext'); ?>" name="<?php echo $this->get_field_name('linktext'); ?>" type="text" value="<?php echo $linktext; ?>" /></label></p> <p><label for="<?php echo $this->get_field_id('linkurl'); ?>"><?php _e('Link Url:', 'theme1473'); ?> <input class="widefat" id="<?php echo $this->get_field_id('linkurl'); ?>" name="<?php echo $this->get_field_name('linkurl'); ?>" type="text" value="<?php echo $linkurl; ?>" /></label></p> <?php } } // class Widget ?>Das benutzerdefinierte Feld habe ich mit folgenden Code eingefügt:
PHP<?php global $wp_query; $postid = $wp_query->post->ID; echo get_post_meta($postid, 'fotograf', true); ?>Das Feld wird 1. nicht im Frontend übernommen und 2. verreist es mir die ganze Seite.
Kann mir jemand weiterhelfen?
Viele Grüße