J'apprécierais vraiment l'aide de quelqu'un dans ce domaine. Fondamentalement, je veux faire un tableau de listes faites à partir d'autres tableaux afin de contourner les limitations de la fonction wordpress 'do_shortcode. Je fais cela en utilisant un certain nombre de fonctions.Retourne le contenu de la liste non ordonnée à partir de la fonction PHP
LONG VERSION DU PROBLÈME:
Le code ressemble actuellement à ceci:
/* These are the functions contained in a functions file */
function output_entry_data() {
$postdate = get_the_date('j/n/y');
$entrytitle = get_the_title();
return ('<li><p class="postmeta">'. $postdate. '</p><h3>'. $entrytitle. '</h3></li>');
}
function output_month_data($entrynomax = '', $month = '', $entrydata = '') {
$entryno = 1;
while($entryno <= $entrynomax) {
echo $entrydata[$entryno];
$entryno++;
}
}
function output_year_data($monthlynomax = '', $year = '', $monthlydata = '') {
$monthno = 1;
while($monthno <= $monthnomax) {
echo do_shortcode('<h4>[slider title="'. $month. '"]</h4><ul>'. $monthlydata[$monthno]. '</ul>[/slider]');
$monthno++;
}
}
/* This is from a loop that determines whether you have reached the end of a month or a year */
$entrydata[$entryno] = output_entry_data();
$entrynomax = $entryno;
$monthlydata = array($monthno => $monthno);
$monthlydata[$monthno] = return(output_month_data($entrynomax, $month, $entrydata));
$monthlynomax = $monthno;
$annualdata[$yearno] = array($yearno => $yearno);
$annualdata[$yearno] = return(output_year_data($monthlynomax, $year, $monthlydata));
$entryno = 1;
$monthno = 1;
$yearno++;
$yearo = get_the_date('Y');
/* The idea is that all the data gets outputted at the end of the loop like this: */
$yearnomax = $yearno;
echo ('<ul>');
$yearno = 1;
if($yearno <= $yearnomax) {
echo do_shortcode('<h3>[expand title ="'. $year. '"]</h3><ul>'. $annualdata[$yearno]. '</ul>[/expand]');
$yearno++;
}
echo('</ul>');
Au moment où le code est crée avec succès le entrydata de $ array [$ entryno] parce que la fonction output_entry_data() renvoie simplement une ligne de code à chaque fois. Cependant, lorsque j'essaie de créer le tableau $ monthlydata [$ monthno] pour chaque mois, il exécute simplement la fonction output_month_data() et fait une grande liste de toutes les entrées mensuelles, plutôt que de transmettre les données au tableau être utilisé par les autres fonctions.
Je vois que c'est parce que je « retour » dans output_entry_data() et « écho » dans output_month_data()
VERSION COURT DU PROBLÈME
Chaque élément du tableau entrydata de $ [$ entryno] est une chaîne contenant une étiquette d'item de liste, je veux que output_monthly_data() retourne une grosse chaîne de tous les items dans $ entrydata [$ entryno] pour être utilisée par d'autres fonctions, plutôt que de les renvoyer comme le code. Cela peut-il être fait quand il y a une boucle de temps impliquée?
Merci beaucoup, j'apprécierais toute contribution ici.