Custom Post Type erstellt nicht vorhanden Zeile
-
Hallo zusammen,
ich hoffe ich bekomme hier Hilfe.
Und zwar habe ich ein Custom Post Type für Ergebnisse bezüglich eines Tischtennisvereins erstellt. Funktioniert super bis auf eine Zeile ganz am Anfang ohne Inhalt, diese Zeile gibt es im System nicht und drückt die Tabelle eine Zeile nach unten, sodass er das letzte Ergebnis nicht lädt. Es ist zudem ein Plugin, damit man es überall auf der Webseite platzieren kann.
Es ist eine Tabelle mit den Spielen.
dazu ein Foto http://badlabs.de/spielplan.png
und der code des Plugins bzw Widget.
<?php class My_Widget extends WP_Widget { /** * Sets up the widgets name etc */ public function __construct() { $widget_ops = array( 'classname' => 'my_widget', 'description' => '', ); parent::__construct( 'my_widget', 'Spieltabelle alle', $widget_ops ); } /** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget( $args, $instance ) { echo '<div class="table"> <div class="row header blue"> <div class="cell"> Datum </div> <div class="cell"> Heim </div> <div class="cell"> Gast </div> <div class="cell"> Spiele </div> </div> '; $postnumber = 999 ; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'sportyresults', 'posts_per_page' => $postnumber, 'paged' => $paged, 'meta_key' => 'sportymatchdate', 'orderby' => 'meta_value', 'order' => 'ASC', ); // The Query $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $dataseason = get_post_meta( get_the_id(), 'sportyseasonselect', true ); $myteamoptional = get_post_meta( get_the_id(), 'sportymyoptionalteam', true ); $opponent = get_post_meta( get_the_id(), 'sportyopponent', true ); $homeoraway = get_post_meta( get_the_id(), 'sportyhomeoraway', true ); $homescore = get_post_meta( get_the_id(), 'sportyhomescore', true ); $awayscore = get_post_meta( get_the_id(), 'sportyawayscore', true ); $matchdate = new DateTime(); $matchdate->setTimestamp(get_post_meta( get_the_id(), 'sportymatchdate', true )); $row_url = get_permalink(); $homescore = str_replace(' ', '', $homescore); $awayscore = str_replace(' ', '', $awayscore); $the_query->the_post(); ?> <div class="row"> <div class="cell" data-title="Datum"> <?php echo $matchdate->format(get_option('date_format')); ?> - <i class="fa fa-clock-o"></i><?php echo $matchdate->format(get_option('time_format')); ?> </div> <div class="cell" data-title="Heim"> <?php echo $myteamoptional; ?> </div> <div class="cell" data-title="Gast"> <?php echo $opponent; ?> </div> <div class="cell" data-title="Spiele"> <?php echo $homescore;?>:<?php echo $awayscore;?> </div> </div> <?php } /* Restore original Post Data */ wp_reset_postdata(); } else { echo "Keine Spiele gefunden"; } /* Restore original Post Data */ wp_reset_postdata(); } /** * Outputs the options form on admin * * @param array $instance The widget options */ public function form( $instance ) { // outputs the options form on admin } /** * Processing widget options on save * * @param array $new_instance The new options * @param array $old_instance The previous options * * @return array */ public function update( $new_instance, $old_instance ) { // processes widget options to be saved } } add_action( 'widgets_init', function(){ register_widget( 'My_Widget' ); }); ?>
Ansicht von 1 Antwort (von insgesamt 1)
Ansicht von 1 Antwort (von insgesamt 1)
- Das Thema „Custom Post Type erstellt nicht vorhanden Zeile“ ist für neue Antworten geschlossen.