I have four arrays that I get from the database unserialize inside a loop, and than get a single value from a loop inside this loop :) Code below:
<?php
// MONTH
$eduGraduationDateMonth = get_post_custom_values('rbeduendmonth');
// YEAR
$eduGraduationDateYear = get_post_custom_values('rbeduendyear');
// PLACE
$eduPlace = get_post_custom_values('rbeduplace');
// FACULTY
$eduFaculty = get_post_custom_values('rbedusubject');
foreach($eduGraduationDateMonth as $eduMonthValue){
$eduMonthUnser = unserialize($eduMonthValue);
foreach($eduMonthUnser as $eduMonthUnserValue){
echo $eduMonthUnserValue;
}
}
foreach($eduGraduationDateYear as $eduYearValue){
$eduYearUnser = unserialize($eduYearValue);
foreach($eduYearUnser as $eduYearUnserValue){
echo $eduYearUnserValue;
}
}
foreach($eduPlace as $eduPlaceValue){
$eduPlaceUnser = unserialize($eduPlaceValue);
foreach($eduPlaceUnser as $eduPlaceUnserValue){
echo $eduPlaceUnserValue;
}
}
foreach($eduFaculty as $eduFacultyValue){
$eduFacultyUnser = unserialize($eduFacultyValue);
foreach($eduFacultyUnser as $eduFacultyUnserValue){
echo $eduFacultyUnserValue;
}
}
?>
Of course when i echo it i get something like: mayseptember19901996College NameAnother CollegeITWriter
What I need is to loop it somehow so i can get the following:
May 1990
College Name
IT
September 1996
Another College
Writer
How could I do that?
Thank you!
just change the order and ad some html elements ..everything is done .updated
<?php
// MONTH
$eduGraduationDateMonth = get_post_custom_values('rbeduendmonth');
// YEAR
$eduGraduationDateYear = get_post_custom_values('rbeduendyear');
// PLACE
$eduPlace = get_post_custom_values('rbeduplace');
// FACULTY
$eduFaculty = get_post_custom_values('rbedusubject');
foreach($eduGraduationDateMonth as $eduMonthValue){
$eduMonthUnser = unserialize($eduMonthValue);
}
foreach($eduGraduationDateYear as $eduYearValue){
$eduYearUnser = unserialize($eduYearValue);
}
foreach($eduPlace as $eduPlaceValue){
$eduPlaceUnser = unserialize($eduPlaceValue);
}
foreach($eduFaculty as $eduFacultyValue){
$eduFacultyUnser = unserialize($eduFacultyValue);
}
foreach($eduMonthUnser as $key =>$value){
echo $value.'<br>';
echo $eduYearUnser[$key].'<br>';
echo $eduPlaceUnser[$key].'<br>';
echo $eduFacultyUnser[$key].'<br>';
}
?>
I have not worked on wordpress but I took a quick look at the documentation: http://codex.wordpress.org/Function_Reference/get_post_custom
You can use get_post_custom()
function and then loop over that. Within each iteration of the loop, access all the keys for that iteration.
Hope this helps.