// основные категории
$categories = get_categories( array(
'parent' => 0
) );
foreach ( $categories as $category ) {
// подкатегории
$sub_categories = get_categories( array(
'parent' => $category->term_id
) );
foreach ( $sub_categories as $sub_category ) {
// записи
$posts = get_posts( array(
'category' => $sub_category->term_id,
'posts_per_page' => 5,
'orderby' => 'date',
) );
foreach ( $posts as $post ) {
// вывод поста и фото
}
}
}
.container {
width: 960px;
margin: 0 auto;
}
.col-4 {
width: 33.33%;
}
<body>
<div class="container">
<div class="col-4">
content
</div>
<div class="col-4">
content
</div>
<div class="col-4">
content
</div>
</div>
</body>
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
var fieldValue = $('input[name="name"]').val();
SELECT `name`, COUNT(*) as `c`
FROM `table`
GROUP BY `name`
HAVING `c` > 1
class Department extends \yii\db\ActiveRecord {
/**
* @return \yii\db\ActiveQuery
*/
public function getBuildings() {
return $this->hasMany(Building::className(), ['department_id' => 'id']);
}
// ...
}
var_dump($department->buildings);
class Building extends \yii\db\ActiveRecord {
/**
* @return \yii\db\ActiveQuery
*/
public function getDepartment() {
return $this->hasOne(Department::className(), ['id' => 'department_id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getRooms() {
return $this->hasMany(Room::className(), ['building_id' => 'id']);
}
// ...
}
var_dump($building->department);
var_dump($building->rooms);
class Room extends \yii\db\ActiveRecord {
/**
* @return \yii\db\ActiveQuery
*/
public function getBuilding() {
return $this->hasOne(Building::className(), ['id' => 'building_id']);
}
// ...
}
var_dump($room->building);
$car->options