Last active
January 20, 2016 06:40
-
-
Save pixelbart/87a3ff8e5fea5e382460 to your computer and use it in GitHub Desktop.
Blöder Fehler, den ich nicht gelöst bekomme... oder weil ich irgendwas übersehe!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Problem: Die Ausgaben der anderen Personen werden hier auch angezeigt. Die, die keine haben, verursachen ein Problem | |
in Form von "Die Seite ist blank". | |
Die Ausgabe: | |
Ein Feld aus dem Profil des Benutzers, wo er eingetragen hat, welche Spiele er mag. Die Ausgabe im Frontend (hier) zeigt lediglich den Inhalt | |
des Feldes + dem passendem Label. | |
Ohne die Schleife etc. funktioniert das einwandfrei. | |
*/ | |
$gpt_general = array( | |
'gpt_game' => array( | |
'id' => 'gpt_game', // Kann beinhalten: Diablo 3, Sims, Fallout, The Witcher 3 | |
'css' => '', // Platzhalter | |
'label' => _e('Spielt gerade', $textdomain), // Text für Label | |
), | |
); | |
function name_to_slug($var) { | |
$var = ltrim($var); | |
$var = str_replace(' ', '-', $var); | |
$var = strtolower($var); | |
return $var | |
} | |
if( get_post_meta( get_the_ID(), $gpt_general['gpt_game']['id'], true ) ) != null ) { | |
$tags1 = explode(',', get_post_meta( get_the_ID(), $gpt_general['gpt_game']['id'], true ) ); // Eingaben trennen | |
foreach($tags1 as $tag1) { // Schleife um die getrennten Tags auszugeben | |
$result1 .= '<a href="/tag/'.name_to_slug($tag1).'">'.ltrim($tag1).'</a>, '; // Ausgaben in eine Variable packen | |
} | |
?> | |
<div class="<?php echo $gpt_gaming['gpt_game']['css']; ?>"> | |
<span><?php echo $gpt_gaming['gpt_game']['label']; ?></span> | |
<?php rtrim($result1, ', '); ?> <!-- Ausgabe --> | |
</div> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment