에서 정렬되지 않은 목록 내용을 반환합니다. 정말 도움이됩니다. 기본적으로 나는 워드 프레스 'do_shortcode 함수의 한계를 극복하기 위해 다른 배열로 만든 목록 배열을 만들고 싶다. 여러 가지 기능을 사용하여이 작업을 수행하고 있습니다. 문제함수 PHP
LONG VERSION :
코드은 다음과 같다 : 순간
/* 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>');
코드 성공적은 $ entrydata를 생성한다 [$ entryno] 배열 때문에 함수 output_entry_data() 매번 코드 행을 반환합니다.
그러나 매월 배열 $ monthlydata [$ monthno]를 만들려고하면 단순히 output_month_data() 함수를 실행하고 배열에 데이터를 전달하는 대신 모든 월별 항목의 큰 목록을 만듭니다 다른 기능들에 의해 사용된다.
I는 I 문제
배열 $의 entrydata 각 아이템 output_entry_data (에 '창')와 "에코"output_month_data에서()
SHORT VERSION를 사용하기 때문에 이것은 [$임을 알 수 entryno]는 목록 항목 태그를 포함하는 문자열입니다. $ entrydata [$ entryno]에있는 모든 항목 중 하나의 큰 문자열을 다른 함수가 사용하도록 코드를 반환하는 대신 현재 코드와 같이 echo합니다. while 루프가 포함될 때이 작업을 수행 할 수 있습니까?
많은 분들께 감사드립니다.